-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
tests/metaworld/envs/mujoco/sawyer_xyz/test_seeded_rand_vec.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import random | ||
|
||
import pytest | ||
import numpy as np | ||
|
||
from metaworld.envs import ALL_V2_ENVIRONMENTS_GOAL_OBSERVABLE | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'env_name', | ||
sorted(ALL_V2_ENVIRONMENTS_GOAL_OBSERVABLE.keys())) | ||
def test_observations_match(env_name): | ||
seed = random.randrange(1000) | ||
env1 = ALL_V2_ENVIRONMENTS_GOAL_OBSERVABLE[env_name](seed=seed) | ||
env1.seeded_rand_vec = True | ||
env2 = ALL_V2_ENVIRONMENTS_GOAL_OBSERVABLE[env_name](seed=seed) | ||
env2.seeded_rand_vec = True | ||
|
||
obs1, obs2 = env1.reset(), env2.reset() | ||
assert (obs1 == obs2).all() | ||
|
||
for i in range(env1.max_path_length): | ||
a = np.random.uniform(low=-1, high=-1, size=4) | ||
obs1, r1, done1, _ = env1.step(a) | ||
obs2, r2, done2, _ = env2.step(a) | ||
assert (obs1 == obs2).all() | ||
assert r1 == r2 | ||
assert not done1 | ||
assert not done2 |