Skip to content

Commit

Permalink
Collection.Mapping deprecated for python +3.10 (#181)
Browse files Browse the repository at this point in the history
When trying to use kitchen environments with a python version +3.10 ,  collection.Mapping throws an error as it is now deprecated. 

Changing this to collection.abc.Mapping.  This is backwards compatible with all  Python >= 3.3
  • Loading branch information
idigitopia authored Oct 20, 2022
1 parent 2b96431 commit 4cef39b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions d4rl/kitchen/adept_envs/mujoco_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(self,
try:
self.action_space = spaces.Box(
act_lower, act_upper, dtype=np.float32)
if isinstance(observation, collections.Mapping):
if isinstance(observation, collections.abc.Mapping):
self.observation_space = spaces.Dict({
k: spaces.Box(-np.inf, np.inf, shape=v.shape, dtype=np.float32) for k, v in observation.items()})
else:
Expand All @@ -98,7 +98,7 @@ def __init__(self,
except TypeError:
# Fallback case for gym 0.9.x
self.action_space = spaces.Box(act_lower, act_upper)
assert not isinstance(observation, collections.Mapping), 'gym 0.9.x does not support dictionary observation.'
assert not isinstance(observation, collections.abc.Mapping), 'gym 0.9.x does not support dictionary observation.'
self.obs_dim = np.sum([o.size for o in observation]) if type(observation) is tuple else observation.size
self.observation_space = spaces.Box(
-np.inf, np.inf, observation.shape)
Expand Down

0 comments on commit 4cef39b

Please sign in to comment.