Skip to content

Commit

Permalink
2to3: apply dict fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
keszybz committed Feb 27, 2022
1 parent 882ed79 commit 7d372b1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions deap/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def __init__(self):

dict_inst = {}
dict_cls = {}
for obj_name, obj in kargs.iteritems():
for obj_name, obj in kargs.items():
if isinstance(obj, type):
dict_inst[obj_name] = obj
else:
Expand All @@ -161,7 +161,7 @@ def initType(self, *args, **kargs):
"""Replace the __init__ function of the new type, in order to
add attributes that were defined with **kargs to the instance.
"""
for obj_name, obj in dict_inst.iteritems():
for obj_name, obj in dict_inst.items():
setattr(self, obj_name, obj())
if base.__init__ is not object.__init__:
base.__init__(self, *args, **kargs)
Expand Down
2 changes: 1 addition & 1 deletion deap/tools/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def compile(self, data):
values = tuple(self.key(elem) for elem in data)

entry = dict()
for key, func in self.functions.iteritems():
for key, func in self.functions.items():
entry[key] = func(values)
return entry

Expand Down
6 changes: 3 additions & 3 deletions doc/code/tutorials/part_4/sortingnetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def addConnector(self, wire1, wire2):
self.append({wire1: wire2})
return

for wires in last_level.iteritems():
for wires in last_level.items():
if wires[1] >= wire1 and wires[0] <= wire2:
self.append({wire1: wire2})
return
Expand All @@ -65,7 +65,7 @@ def addConnector(self, wire1, wire2):
def sort(self, values):
"""Sort the values in-place based on the connectors in the network."""
for level in self:
for wire1, wire2 in level.iteritems():
for wire1, wire2 in level.items():
if values[wire1] > values[wire2]:
values[wire1], values[wire2] = values[wire2], values[wire1]

Expand Down Expand Up @@ -99,7 +99,7 @@ def draw(self):
str_wires[i][1] = " o"

for index, level in enumerate(self):
for wire1, wire2 in level.iteritems():
for wire1, wire2 in level.items():
str_wires[wire1][(index+1)*6] = "x"
str_wires[wire2][(index+1)*6] = "x"
for i in range(wire1, wire2):
Expand Down

0 comments on commit 7d372b1

Please sign in to comment.