diff --git a/src/lerobot/datasets/utils.py b/src/lerobot/datasets/utils.py index c78f16cd2..f6a5cb4c7 100644 --- a/src/lerobot/datasets/utils.py +++ b/src/lerobot/datasets/utils.py @@ -20,7 +20,6 @@ import logging from collections.abc import Iterator from pathlib import Path from pprint import pformat -from types import SimpleNamespace from typing import Any import datasets @@ -645,61 +644,6 @@ def create_lerobot_dataset_card( ) -class IterableNamespace(SimpleNamespace): - """ - A namespace object that supports both dictionary-like iteration and dot notation access. - Automatically converts nested dictionaries into IterableNamespaces. - - This class extends SimpleNamespace to provide: - - Dictionary-style iteration over keys - - Access to items via both dot notation (obj.key) and brackets (obj["key"]) - - Dictionary-like methods: items(), keys(), values() - - Recursive conversion of nested dictionaries - - Args: - dictionary: Optional dictionary to initialize the namespace - **kwargs: Additional keyword arguments passed to SimpleNamespace - - Examples: - >>> data = {"name": "Alice", "details": {"age": 25}} - >>> ns = IterableNamespace(data) - >>> ns.name - 'Alice' - >>> ns.details.age - 25 - >>> list(ns.keys()) - ['name', 'details'] - >>> for key, value in ns.items(): - ... print(f"{key}: {value}") - name: Alice - details: IterableNamespace(age=25) - """ - - def __init__(self, dictionary: dict[str, Any] = None, **kwargs): - super().__init__(**kwargs) - if dictionary is not None: - for key, value in dictionary.items(): - if isinstance(value, dict): - setattr(self, key, IterableNamespace(value)) - else: - setattr(self, key, value) - - def __iter__(self) -> Iterator[str]: - return iter(vars(self)) - - def __getitem__(self, key: str) -> Any: - return vars(self)[key] - - def items(self): - return vars(self).items() - - def values(self): - return vars(self).values() - - def keys(self): - return vars(self).keys() - - def validate_frame(frame: dict, features: dict) -> None: expected_features = set(features) - set(DEFAULT_FEATURES) actual_features = set(frame)