diff --git a/lerobot/common/datasets/lerobot_dataset.py b/lerobot/common/datasets/lerobot_dataset.py index 6ef955dd..d8da85d6 100644 --- a/lerobot/common/datasets/lerobot_dataset.py +++ b/lerobot/common/datasets/lerobot_dataset.py @@ -1053,7 +1053,7 @@ class MultiLeRobotDataset(torch.utils.data.Dataset): super().__init__() self.repo_ids = repo_ids self.root = Path(root) if root else HF_LEROBOT_HOME - self.tolerances_s = tolerances_s if tolerances_s else {repo_id: 1e-4 for repo_id in repo_ids} + self.tolerances_s = tolerances_s if tolerances_s else dict.fromkeys(repo_ids, 0.0001) # Construct the underlying datasets passing everything but `transform` and `delta_timestamps` which # are handled by this class. self._datasets = [ diff --git a/lerobot/common/datasets/utils.py b/lerobot/common/datasets/utils.py index 7e297b35..9d8a54db 100644 --- a/lerobot/common/datasets/utils.py +++ b/lerobot/common/datasets/utils.py @@ -240,7 +240,7 @@ def load_episodes_stats(local_dir: Path) -> dict: def backward_compatible_episodes_stats( stats: dict[str, dict[str, np.ndarray]], episodes: list[int] ) -> dict[str, dict[str, np.ndarray]]: - return {ep_idx: stats for ep_idx in episodes} + return dict.fromkeys(episodes, stats) def load_image_as_numpy( diff --git a/lerobot/common/datasets/v2/convert_dataset_v1_to_v2.py b/lerobot/common/datasets/v2/convert_dataset_v1_to_v2.py index acf0282f..024576d7 100644 --- a/lerobot/common/datasets/v2/convert_dataset_v1_to_v2.py +++ b/lerobot/common/datasets/v2/convert_dataset_v1_to_v2.py @@ -481,7 +481,7 @@ def convert_dataset( # Tasks if single_task: - tasks_by_episodes = {ep_idx: single_task for ep_idx in episode_indices} + tasks_by_episodes = dict.fromkeys(episode_indices, single_task) dataset, tasks = add_task_index_by_episodes(dataset, tasks_by_episodes) tasks_by_episodes = {ep_idx: [task] for ep_idx, task in tasks_by_episodes.items()} elif tasks_path: diff --git a/lerobot/common/utils/logging_utils.py b/lerobot/common/utils/logging_utils.py index b99c348f..56c9abb2 100644 --- a/lerobot/common/utils/logging_utils.py +++ b/lerobot/common/utils/logging_utils.py @@ -94,7 +94,7 @@ class MetricsTracker: metrics: dict[str, AverageMeter], initial_step: int = 0, ): - self.__dict__.update({k: None for k in self.__keys__}) + self.__dict__.update(dict.fromkeys(self.__keys__)) self._batch_size = batch_size self._num_frames = num_frames self._avg_samples_per_ep = num_frames / num_episodes