Skip to content

Commit

Permalink
Fix pickle env testing
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudo-rnd-thoughts committed Apr 18, 2024
1 parent 6a8a267 commit ca84fb9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/envs/test_envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,17 @@ def test_pickle_env(env: gym.Env):
if env.metadata.get("jax", False):
env = gym.wrappers.JaxToNumpy(env)

action = env.action_space.sample()

env_reset = env.reset(seed=123)
env_step = env.step(action)

pickled_env = pickle.loads(pickle.dumps(env))
pickle_reset = pickled_env.reset(seed=123)
pickle_step = pickled_env.step(action)

data_equivalence(env.reset(), pickled_env.reset())
assert data_equivalence(env_reset, pickle_reset)
assert data_equivalence(env_step, pickle_step)

action = env.action_space.sample()
data_equivalence(env.step(action), pickled_env.step(action))
env.close()
pickled_env.close()

0 comments on commit ca84fb9

Please sign in to comment.