Skip to content

Commit

Permalink
updating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
reginald-mclean committed Aug 30, 2024
1 parent a63a024 commit 0f8d38e
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 65 deletions.
2 changes: 1 addition & 1 deletion scripts/policy_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
np.set_printoptions(suppress=True)

seed = 42
env_name = "door-lock-V3"
env_name = "door-lock-v3"

random.seed(seed)
ml1 = metaworld.MT50(seed=seed)
Expand Down
18 changes: 9 additions & 9 deletions tests/integration/test_new_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,15 @@ def check_target_poss_unique(env_instances, env_rand_vecs):
"""Verify that all the state_goals are unique for the different rand_vecs that are sampled.
Note: The following envs randomize object initial position but not state_goal.
['hammer-V3', 'sweep-into-V3', 'bin-picking-V3', 'basketball-V3']
['hammer-v3', 'sweep-into-v3', 'bin-picking-v3', 'basketball-v3']
"""
for env_name, rand_vecs in env_rand_vecs.items():
if env_name in {
"hammer-V3",
"sweep-into-V3",
"bin-picking-V3",
"basketball-V3",
"hammer-v3",
"sweep-into-v3",
"bin-picking-v3",
"basketball-v3",
}:
continue
env = env_instances[env_name]
Expand Down Expand Up @@ -289,13 +289,13 @@ def helper_neq(env, env_2):
assert not (rand_vec_1 == rand_vec_2).all()

# testing MT1
mt1_1 = metaworld.MT1("sweep-into-V3", seed=10)
mt1_2 = metaworld.MT1("sweep-into-V3", seed=10)
mt1_1 = metaworld.MT1("sweep-into-v3", seed=10)
mt1_2 = metaworld.MT1("sweep-into-v3", seed=10)
helper(mt1_1, mt1_2)

# testing ML1
ml1_1 = metaworld.ML1("sweep-into-V3", seed=10)
ml1_2 = metaworld.ML1("sweep-into-V3", seed=10)
ml1_1 = metaworld.ML1("sweep-into-v3", seed=10)
ml1_2 = metaworld.ML1("sweep-into-v3", seed=10)
helper(ml1_1, ml1_2)

# testing MT10
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_single_goal_envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_observable_goal_envs():

def test_seeding_observable():
door_open_goal_observable_cls = ALL_V3_ENVIRONMENTS_GOAL_OBSERVABLE[
"door-open-V3-goal-observable"
"door-open-v3-goal-observable"
]

env1 = door_open_goal_observable_cls(seed=5)
Expand Down Expand Up @@ -106,7 +106,7 @@ def test_seeding_observable():

def test_seeding_hidden():
door_open_goal_hidden_cls = ALL_V3_ENVIRONMENTS_GOAL_HIDDEN[
"door-open-V3-goal-hidden"
"door-open-v3-goal-hidden"
]

env1 = door_open_goal_hidden_cls(seed=5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def sample_spherical(num_points, radius=1.0):

@pytest.mark.parametrize("target", sample_spherical(100, 10.0))
def test_reaching_limit(target):
env = ALL_V3_ENVIRONMENTS["reach-V3"]()
env = ALL_V3_ENVIRONMENTS["reach-v3"]()
env._partially_observable = False
env._freeze_rand_vec = False
env._set_task_called = True
Expand Down
103 changes: 51 additions & 52 deletions tests/metaworld/envs/mujoco/sawyer_xyz/test_scripted_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,56 +56,56 @@

policies = dict(
{
"assembly-V3": SawyerAssemblyV3Policy,
"basketball-V3": SawyerBasketballV3Policy,
"bin-picking-V3": SawyerBinPickingV3Policy,
"box-close-V3": SawyerBoxCloseV3Policy,
"button-press-topdown-V3": SawyerButtonPressTopdownV3Policy,
"button-press-topdown-wall-V3": SawyerButtonPressTopdownWallV3Policy,
"button-press-V3": SawyerButtonPressV3Policy,
"button-press-wall-V3": SawyerButtonPressWallV3Policy,
"coffee-button-V3": SawyerCoffeeButtonV3Policy,
"coffee-pull-V3": SawyerCoffeePullV3Policy,
"coffee-push-V3": SawyerCoffeePushV3Policy,
"dial-turn-V3": SawyerDialTurnV3Policy,
"disassemble-V3": SawyerDisassembleV3Policy,
"door-close-V3": SawyerDoorCloseV3Policy,
"door-lock-V3": SawyerDoorLockV3Policy,
"door-open-V3": SawyerDoorOpenV3Policy,
"door-unlock-V3": SawyerDoorUnlockV3Policy,
"drawer-close-V3": SawyerDrawerCloseV3Policy,
"drawer-open-V3": SawyerDrawerOpenV3Policy,
"faucet-close-V3": SawyerFaucetCloseV3Policy,
"faucet-open-V3": SawyerFaucetOpenV3Policy,
"hammer-V3": SawyerHammerV3Policy,
"hand-insert-V3": SawyerHandInsertV3Policy,
"handle-press-side-V3": SawyerHandlePressSideV3Policy,
"handle-press-V3": SawyerHandlePressV3Policy,
"handle-pull-V3": SawyerHandlePullV3Policy,
"handle-pull-side-V3": SawyerHandlePullSideV3Policy,
"peg-insert-side-V3": SawyerPegInsertionSideV3Policy,
"lever-pull-V3": SawyerLeverPullV3Policy,
"peg-unplug-side-V3": SawyerPegUnplugSideV3Policy,
"pick-out-of-hole-V3": SawyerPickOutOfHoleV3Policy,
"pick-place-V3": SawyerPickPlaceV3Policy,
"pick-place-wall-V3": SawyerPickPlaceWallV3Policy,
"plate-slide-back-side-V3": SawyerPlateSlideBackSideV3Policy,
"plate-slide-back-V3": SawyerPlateSlideBackV3Policy,
"plate-slide-side-V3": SawyerPlateSlideSideV3Policy,
"plate-slide-V3": SawyerPlateSlideV3Policy,
"reach-V3": SawyerReachV3Policy,
"reach-wall-V3": SawyerReachWallV3Policy,
"push-back-V3": SawyerPushBackV3Policy,
"push-V3": SawyerPushV3Policy,
"push-wall-V3": SawyerPushWallV3Policy,
"shelf-place-V3": SawyerShelfPlaceV3Policy,
"soccer-V3": SawyerSoccerV3Policy,
"stick-pull-V3": SawyerStickPullV3Policy,
"stick-push-V3": SawyerStickPushV3Policy,
"sweep-into-V3": SawyerSweepIntoV3Policy,
"sweep-V3": SawyerSweepV3Policy,
"window-close-V3": SawyerWindowCloseV3Policy,
"window-open-V3": SawyerWindowOpenV3Policy,
"assembly-v3": SawyerAssemblyV3Policy,
"basketball-v3": SawyerBasketballV3Policy,
"bin-picking-v3": SawyerBinPickingV3Policy,
"box-close-v3": SawyerBoxCloseV3Policy,
"button-press-topdown-v3": SawyerButtonPressTopdownV3Policy,
"button-press-topdown-wall-v3": SawyerButtonPressTopdownWallV3Policy,
"button-press-v3": SawyerButtonPressV3Policy,
"button-press-wall-v3": SawyerButtonPressWallV3Policy,
"coffee-button-v3": SawyerCoffeeButtonV3Policy,
"coffee-pull-v3": SawyerCoffeePullV3Policy,
"coffee-push-v3": SawyerCoffeePushV3Policy,
"dial-turn-v3": SawyerDialTurnV3Policy,
"disassemble-v3": SawyerDisassembleV3Policy,
"door-close-v3": SawyerDoorCloseV3Policy,
"door-lock-v3": SawyerDoorLockV3Policy,
"door-open-v3": SawyerDoorOpenV3Policy,
"door-unlock-v3": SawyerDoorUnlockV3Policy,
"drawer-close-v3": SawyerDrawerCloseV3Policy,
"drawer-open-v3": SawyerDrawerOpenV3Policy,
"faucet-close-v3": SawyerFaucetCloseV3Policy,
"faucet-open-v3": SawyerFaucetOpenV3Policy,
"hammer-v3": SawyerHammerV3Policy,
"hand-insert-v3": SawyerHandInsertV3Policy,
"handle-press-side-v3": SawyerHandlePressSideV3Policy,
"handle-press-v3": SawyerHandlePressV3Policy,
"handle-pull-v3": SawyerHandlePullV3Policy,
"handle-pull-side-v3": SawyerHandlePullSideV3Policy,
"peg-insert-side-v3": SawyerPegInsertionSideV3Policy,
"lever-pull-v3": SawyerLeverPullV3Policy,
"peg-unplug-side-v3": SawyerPegUnplugSideV3Policy,
"pick-out-of-hole-v3": SawyerPickOutOfHoleV3Policy,
"pick-place-v3": SawyerPickPlaceV3Policy,
"pick-place-wall-v3": SawyerPickPlaceWallV3Policy,
"plate-slide-back-side-v3": SawyerPlateSlideBackSideV3Policy,
"plate-slide-back-v3": SawyerPlateSlideBackV3Policy,
"plate-slide-side-v3": SawyerPlateSlideSideV3Policy,
"plate-slide-v3": SawyerPlateSlideV3Policy,
"reach-v3": SawyerReachV3Policy,
"reach-wall-v3": SawyerReachWallV3Policy,
"push-back-v3": SawyerPushBackV3Policy,
"push-v3": SawyerPushV3Policy,
"push-wall-v3": SawyerPushWallV3Policy,
"shelf-place-v3": SawyerShelfPlaceV3Policy,
"soccer-v3": SawyerSoccerV3Policy,
"stick-pull-v3": SawyerStickPullV3Policy,
"stick-push-v3": SawyerStickPushV3Policy,
"sweep-into-v3": SawyerSweepIntoV3Policy,
"sweep-v3": SawyerSweepV3Policy,
"window-close-v3": SawyerWindowCloseV3Policy,
"window-open-v3": SawyerWindowOpenV3Policy,
}
)

Expand All @@ -130,5 +130,4 @@ def test_policy(env_name):
if int(info["success"]) == 1:
completed += 1
break
print(float(completed) / 50)
assert (float(completed) / 50) > 0.80
assert (float(completed) / 50) >= 0.80

0 comments on commit 0f8d38e

Please sign in to comment.