Skip to content

Commit

Permalink
Improve Wrapper and VectorWrapper error checking (#1260)
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudo-rnd-thoughts authored Nov 22, 2024
1 parent 9ba3283 commit 13230f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion gymnasium/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ def __init__(self, env: Env[ObsType, ActType]):
env: The environment to wrap
"""
self.env = env
assert isinstance(env, Env)
assert isinstance(
env, Env
), f"Expected env to be a `gymnasium.Env` but got {type(env)}"

self._action_space: spaces.Space[WrapperActType] | None = None
self._observation_space: spaces.Space[WrapperObsType] | None = None
Expand Down
4 changes: 3 additions & 1 deletion gymnasium/vector/vector_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ def __init__(self, env: VectorEnv):
env: The environment to wrap
"""
self.env = env
assert isinstance(env, VectorEnv)
assert isinstance(
env, VectorEnv
), f"Expected env to be a `gymnasium.vector.VectorEnv` but got {type(env)}"

self._observation_space: gym.Space | None = None
self._action_space: gym.Space | None = None
Expand Down

0 comments on commit 13230f4

Please sign in to comment.