diff --git a/tests/datasets/test_datasets.py b/tests/datasets/test_datasets.py index 19c314fd6..1d2fb1d55 100644 --- a/tests/datasets/test_datasets.py +++ b/tests/datasets/test_datasets.py @@ -51,7 +51,7 @@ from lerobot.robots import make_robot_from_config from lerobot.transforms import ImageTransforms, ImageTransformsConfig from lerobot.utils.constants import ACTION, DONE, OBS_IMAGES, OBS_STATE, OBS_STR, REWARD from lerobot.utils.feature_utils import hw_to_dataset_features -from tests.fixtures.constants import DUMMY_CHW, DUMMY_HWC, DUMMY_REPO_ID +from tests.fixtures.constants import DUMMY_CHW, DUMMY_HWC, DUMMY_MOTOR_FEATURES, DUMMY_REPO_ID from tests.mocks.mock_robot import MockRobotConfig from tests.utils import require_x86_64_kernel @@ -133,6 +133,21 @@ def test_dataset_feature_with_forward_slash_raises_error(): ) +def test_create_does_not_mutate_input_features(tmp_path, empty_lerobot_dataset_factory): + # ``create`` must deep-copy features so a dataset built from another's features stays independent. + dataset = empty_lerobot_dataset_factory( + root=tmp_path / "ds1", features=DUMMY_MOTOR_FEATURES, use_videos=False + ) + dataset_copy = empty_lerobot_dataset_factory( + root=tmp_path / "ds2", features=dataset.meta.features, use_videos=False + ) + + original_shape = dataset.meta.info.features["state"]["shape"] + dataset_copy.meta.info.features["state"]["shape"] = (999,) + + assert dataset.meta.info.features["state"]["shape"] == original_shape + + def test_add_frame_missing_task(tmp_path, empty_lerobot_dataset_factory): features = {"state": {"dtype": "float32", "shape": (1,), "names": None}} dataset = empty_lerobot_dataset_factory(root=tmp_path / "test", features=features)