mirror of
https://github.com/wassname/pyrobolearn.git
synced 2026-09-09 11:31:38 +08:00
fix minor compatibility errors with Py3.*
This commit is contained in:
@@ -232,7 +232,7 @@ class Updater(object):
|
||||
raise TypeError("Expecting the given ticks to be a dictionary, instead got: {}".format(type(ticks)))
|
||||
|
||||
# check first the items already present in the ticks
|
||||
for key, value in ticks.iteritems():
|
||||
for key, value in ticks.items():
|
||||
# check that the key is a Loss or ParamaterUpdater
|
||||
if not isinstance(key, (Loss, ParameterUpdater)):
|
||||
raise TypeError("Expecting the given key for the tick to be an instance of `Loss` or "
|
||||
|
||||
@@ -380,7 +380,7 @@ class ExperienceReplay(DictStorage): # ExperienceReplayStorage(DictStorage):
|
||||
batch = {}
|
||||
|
||||
# go through each attribute in the and sample from the tensors
|
||||
for key, value in self.iteritems():
|
||||
for key, value in self.items():
|
||||
if isinstance(value, list): # value = list of tensors
|
||||
batch[key] = [val[indices] for val in value]
|
||||
else: # value = tensor
|
||||
|
||||
@@ -686,7 +686,7 @@ class Batch(DictStorage):
|
||||
|
||||
# print other variables
|
||||
tmp = {'states', 'actions', 'rewards', 'masks', 'returns'}
|
||||
for key, value in kwargs.iteritems():
|
||||
for key, value in kwargs.items():
|
||||
if key not in tmp:
|
||||
print("{}: {}".format(key, value))
|
||||
|
||||
@@ -1166,7 +1166,7 @@ class RolloutStorage(DictStorage): # TODO: think about when multiple policies:
|
||||
# print("Indices: {}".format(indices))
|
||||
|
||||
# go through each attribute and sample from the tensors
|
||||
for key, value in self.iteritems():
|
||||
for key, value in self.items():
|
||||
# print("batch - add key: {}".format(key))
|
||||
if isinstance(value, list): # value = list of tensors
|
||||
batch[key] = [sample(val, indices) for val in value] # [[I, *shape] for each shape]
|
||||
|
||||
@@ -269,7 +269,7 @@ class World(object):
|
||||
world = self.__class__(simulator=simulator, gravity=gravity)
|
||||
|
||||
# load bodies in world
|
||||
for id_, items in self.ids.iteritems():
|
||||
for id_, items in self.ids.items():
|
||||
if not isinstance(items, list):
|
||||
items = [items]
|
||||
for item in items:
|
||||
|
||||
Reference in New Issue
Block a user