Skip to content

Commit

Permalink
'HumanRendering' object has no attribute 'window' (Farama-Foundation#…
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerJL authored Jun 10, 2024
1 parent bff8824 commit b58207f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions gymnasium/wrappers/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,17 +472,17 @@ def __init__(self, env: gym.Env[ObsType, ActType]):
gym.utils.RecordConstructorArgs.__init__(self)
gym.Wrapper.__init__(self, env)

self.screen_size = None
self.window = None # Has to be initialized before asserts, as self.window is used in auto close
self.clock = None

assert (
self.env.render_mode in self.ACCEPTED_RENDER_MODES
), f"Expected env.render_mode to be one of {self.ACCEPTED_RENDER_MODES} but got '{env.render_mode}'"
assert (
"render_fps" in self.env.metadata
), "The base environment must specify 'render_fps' to be used with the HumanRendering wrapper"

self.screen_size = None
self.window = None
self.clock = None

if "human" not in self.metadata["render_modes"]:
self.metadata = deepcopy(self.env.metadata)
self.metadata["render_modes"].append("human")
Expand Down
10 changes: 5 additions & 5 deletions gymnasium/wrappers/vector/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ def __init__(self, env: VectorEnv, screen_size: tuple[int, int] | None = None):
"""
VectorWrapper.__init__(self, env)

self.screen_size = screen_size
self.scaled_subenv_size, self.num_rows, self.num_cols = None, None, None
self.window = None # Has to be initialized before asserts, as self.window is used in auto close
self.clock = None

assert (
self.env.render_mode in self.ACCEPTED_RENDER_MODES
), f"Expected env.render_mode to be one of {self.ACCEPTED_RENDER_MODES} but got '{env.render_mode}'"
assert (
"render_fps" in self.env.metadata
), "The base environment must specify 'render_fps' to be used with the HumanRendering wrapper"

self.screen_size = screen_size
self.scaled_subenv_size, self.num_rows, self.num_cols = None, None, None
self.window = None
self.clock = None

if "human" not in self.metadata["render_modes"]:
self.metadata = deepcopy(self.env.metadata)
self.metadata["render_modes"].append("human")
Expand Down

0 comments on commit b58207f

Please sign in to comment.