Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'HumanRendering' object has no attribute 'window' (#1078) #1079

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading