fixed minor back with __getattr__

This commit is contained in:
ottofabian
2021-07-02 18:18:11 +02:00
parent 4fafe86764
commit 92f1f409f3
3 changed files with 12 additions and 8 deletions
+7 -3
View File
@@ -91,9 +91,13 @@ class DMCWrapper(core.Env):
# set seed
self.seed(seed=task_kwargs.get('random', 1))
def __getattr__(self, name):
"""Delegate attribute access to underlying environment."""
return getattr(self._env, name)
def __getattr__(self, item):
"""Propagate only non-existent properties to wrapped env."""
if item.startswith('_'):
raise AttributeError("attempted to get missing private attribute '{}'".format(item))
if item in self.__dict__:
return getattr(self, item)
return getattr(self._env, item)
def _get_obs(self, time_step):
if self._from_pixels: