fix style

This commit is contained in:
Jade Choghari
2025-11-11 00:17:31 +01:00
parent 6001b2c3ad
commit c11d8f1bb6
2 changed files with 28 additions and 30 deletions
+5 -7
View File
@@ -37,7 +37,7 @@ def assert_observations_equal(obs1, obs2, path="", atol=1e-8):
"""
if isinstance(obs1, dict) and isinstance(obs2, dict):
assert obs1.keys() == obs2.keys(), f"Keys differ at {path}: {obs1.keys()} != {obs2.keys()}"
for key in obs1.keys():
for key in obs1:
assert_observations_equal(obs1[key], obs2[key], path=f"{path}.{key}" if path else key, atol=atol)
elif isinstance(obs1, np.ndarray) and isinstance(obs2, np.ndarray):
assert obs1.shape == obs2.shape, f"Shape mismatch at {path}: {obs1.shape} != {obs2.shape}"
@@ -46,11 +46,10 @@ def assert_observations_equal(obs1, obs2, path="", atol=1e-8):
f"Array values differ at {path}: max abs diff = {np.abs(obs1 - obs2).max()}"
)
else:
assert type(obs1) == type(obs2), f"Type mismatch at {path}: {type(obs1)} != {type(obs2)}"
assert type(obs1) is type(obs2), f"Type mismatch at {path}: {type(obs1)} != {type(obs2)}"
assert obs1 == obs2, f"Values differ at {path}: {obs1} != {obs2}"
def test_libero_env_creation():
"""Test that the libero environment can be created successfully."""
config = make_env_config("libero", task="libero_spatial")
@@ -70,7 +69,6 @@ def test_libero_env_creation():
env.close()
def test_libero_reset_determinism():
"""Test that resetting with the same seed produces identical observations."""
config = make_env_config("libero", task="libero_spatial")
@@ -90,7 +88,6 @@ def test_libero_reset_determinism():
env.close()
def test_libero_step_determinism():
"""Test that step() is deterministic when resetting with the same seed."""
config = make_env_config("libero", task="libero_spatial")
@@ -116,13 +113,14 @@ def test_libero_step_determinism():
# Rewards and termination flags should be identical
assert np.allclose(reward1, reward2), f"Rewards differ: {reward1} != {reward2}"
assert np.array_equal(terminated1, terminated2), f"Terminated flags differ: {terminated1} != {terminated2}"
assert np.array_equal(terminated1, terminated2), (
f"Terminated flags differ: {terminated1} != {terminated2}"
)
assert np.array_equal(truncated1, truncated2), f"Truncated flags differ: {truncated1} != {truncated2}"
env.close()
@pytest.mark.parametrize("task", ["libero_spatial", "libero_object", "libero_goal", "libero_10"])
def test_libero_tasks(task):
"""Test that different libero tasks can be created and used."""