You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def check_environments_match(
env_a: gym.Env,
env_b: gym.Env,
num_steps: int,
seed: int = None,
skip_obs: bool = False,
skip_rew: bool = False,
skip_terminal: bool = False,
skip_truncated: bool = False,
skip_info: bool = False,
):
"""Checks if the environments `env_a` & `env_b` are identical.
Args:
num_steps: number of timesteps to test for, setting to 0 tests only resetting.
skip_obs: If `True` it does not check for equivalence of the observation.
skip_rew: If `True` it does not check for equivalence of the observation.
skip_terminal: If `True` it does not check for equivalence of the observation.
skip_truncated: If `True` it does not check for equivalence of the observation.
skip_info: If `True` it does not check for equivalence of the observation.
"""
assert env_a.action_space == env_b.action_space
assert skip_obs or env_b.observation_space == env_b.observation_space
obs_a, info_a = env_a.reset(seed)
obs_b, info_b = env_b.reset(seed)
assert skip_obs or data_equivalence(obs_a, obs_b)
assert skip_info or data_equivalence(info_a, info_b)
env_a.action_space.seed(seed)
for _ in range(num_steps):
action = env_a.action_space.sample()
obs_a, rew_a, terminal_a, truncated_a, info_a = env_a.step(action)
obs_b, rew_b, terminal_b, truncated_b, info_b = env_b.step(action)
assert skip_obs or data_equivalence(obs_a, obs_b)
assert skip_rew or data_equivalence(rew_a, rew_b)
assert skip_terminal or terminal_a == terminal_b
assert skip_truncated or truncated_a == truncated_b
assert skip_info or data_equivalence(info_a, info_b)
if terminal_a or truncated_a:
obs_a, info_a = env_a.reset(seed)
obs_b, info_b = env_b.reset(seed)
assert skip_obs or data_equivalence(obs_a, obs_b)
assert skip_info or data_equivalence(info_a, info_b)
Proposal
Add:
Note: pettingzoo has
https://github.com/Farama-Foundation/PettingZoo/blob/969c079164e6fd84b4878f26debfeff644aa2786/pettingzoo/test/seed_test.py#L16
Motivation
It could enable:
Or for any new environment revision.
Pitch
No response
Alternatives
I could simply keep it in
test_mujoco_v5.py
Additional context
No response
Checklist
The text was updated successfully, but these errors were encountered: