mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-27 22:49:48 +00:00
fix style
This commit is contained in:
@@ -37,7 +37,7 @@ def assert_observations_equal(obs1, obs2, path="", atol=1e-8):
|
|||||||
"""
|
"""
|
||||||
if isinstance(obs1, dict) and isinstance(obs2, dict):
|
if isinstance(obs1, dict) and isinstance(obs2, dict):
|
||||||
assert obs1.keys() == obs2.keys(), f"Keys differ at {path}: {obs1.keys()} != {obs2.keys()}"
|
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)
|
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):
|
elif isinstance(obs1, np.ndarray) and isinstance(obs2, np.ndarray):
|
||||||
assert obs1.shape == obs2.shape, f"Shape mismatch at {path}: {obs1.shape} != {obs2.shape}"
|
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()}"
|
f"Array values differ at {path}: max abs diff = {np.abs(obs1 - obs2).max()}"
|
||||||
)
|
)
|
||||||
else:
|
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}"
|
assert obs1 == obs2, f"Values differ at {path}: {obs1} != {obs2}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_libero_env_creation():
|
def test_libero_env_creation():
|
||||||
"""Test that the libero environment can be created successfully."""
|
"""Test that the libero environment can be created successfully."""
|
||||||
config = make_env_config("libero", task="libero_spatial")
|
config = make_env_config("libero", task="libero_spatial")
|
||||||
@@ -70,7 +69,6 @@ def test_libero_env_creation():
|
|||||||
env.close()
|
env.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_libero_reset_determinism():
|
def test_libero_reset_determinism():
|
||||||
"""Test that resetting with the same seed produces identical observations."""
|
"""Test that resetting with the same seed produces identical observations."""
|
||||||
config = make_env_config("libero", task="libero_spatial")
|
config = make_env_config("libero", task="libero_spatial")
|
||||||
@@ -90,7 +88,6 @@ def test_libero_reset_determinism():
|
|||||||
env.close()
|
env.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_libero_step_determinism():
|
def test_libero_step_determinism():
|
||||||
"""Test that step() is deterministic when resetting with the same seed."""
|
"""Test that step() is deterministic when resetting with the same seed."""
|
||||||
config = make_env_config("libero", task="libero_spatial")
|
config = make_env_config("libero", task="libero_spatial")
|
||||||
@@ -116,13 +113,14 @@ def test_libero_step_determinism():
|
|||||||
|
|
||||||
# Rewards and termination flags should be identical
|
# Rewards and termination flags should be identical
|
||||||
assert np.allclose(reward1, reward2), f"Rewards differ: {reward1} != {reward2}"
|
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}"
|
assert np.array_equal(truncated1, truncated2), f"Truncated flags differ: {truncated1} != {truncated2}"
|
||||||
|
|
||||||
env.close()
|
env.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("task", ["libero_spatial", "libero_object", "libero_goal", "libero_10"])
|
@pytest.mark.parametrize("task", ["libero_spatial", "libero_object", "libero_goal", "libero_10"])
|
||||||
def test_libero_tasks(task):
|
def test_libero_tasks(task):
|
||||||
"""Test that different libero tasks can be created and used."""
|
"""Test that different libero tasks can be created and used."""
|
||||||
|
|||||||
Reference in New Issue
Block a user