This is an automated email from the ASF dual-hosted git repository.

JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 59ad511d4c [python] Allow importing LeRobot datasets with unlabeled 
subtask frames (#11059)
59ad511d4c is described below

commit 59ad511d4cf567f33a17c1e5a2f8a450eae47004
Author: XiaoHongbo <[email protected]>
AuthorDate: Tue Nov 10 14:29:03 2026 +0800

    [python] Allow importing LeRobot datasets with unlabeled subtask frames 
(#11059)
---
 docs/docs/pypaimon/lerobot.md                      |   9 +
 .../pypaimon/multimodal/lerobot/dataset.py         |  87 ++++++--
 .../pypaimon/multimodal/lerobot/loader.py          |   2 +
 .../pypaimon/multimodal/lerobot/metadata.py        |  13 +-
 .../pypaimon/multimodal/lerobot/schema.py          |   2 +-
 .../pypaimon/tests/multimodal_lerobot_test.py      | 227 ++++++++++++++++++++-
 6 files changed, 320 insertions(+), 20 deletions(-)

diff --git a/docs/docs/pypaimon/lerobot.md b/docs/docs/pypaimon/lerobot.md
index d5626e66c1..8a07b4b497 100644
--- a/docs/docs/pypaimon/lerobot.md
+++ b/docs/docs/pypaimon/lerobot.md
@@ -35,6 +35,10 @@ and optional `<table>__stats` and `<table>__subtasks` 
companion tables. Task tex
 remains in the task table; frames retain `task_index`. All imported tables use
 Data Evolution with row tracking.
 
+Frames with a null `subtask_index` are imported. `PaimonLeRobotDataset[index]`
+returns `None` for `subtask_index` and `subtask`. DataLoader batches use a
+validity mask for missing indices (see training below).
+
 Info and stats use `key STRING, value STRING`: each top-level info property or
 stats feature becomes one row. Each value is JSON-encoded, preserving nested
 objects, arrays, nulls, and scalar types. Decode it with `json.loads`; for 
example,
@@ -230,6 +234,11 @@ pin one named snapshot on every component.
 
 ## Train with Paimon LeRobot data
 
+For datasets with `subtask_index`, `to_dataloader()` always returns integer
+`subtask_index` tensors and matching boolean `subtask_index_is_valid` masks,
+including time windows. Missing labels use `-1` with a false mask; individual
+sample reads retain `None`.
+
 For map-style training, pass an image- or video-backed table group created by
 `load_from_lerobot` to `PaimonLeRobotDataset`. A frame-only table created by
 `PaimonLeRobotWriter` is not sufficient.
diff --git a/paimon-python/pypaimon/multimodal/lerobot/dataset.py 
b/paimon-python/pypaimon/multimodal/lerobot/dataset.py
index ceac2444fb..393ce7f95a 100644
--- a/paimon-python/pypaimon/multimodal/lerobot/dataset.py
+++ b/paimon-python/pypaimon/multimodal/lerobot/dataset.py
@@ -534,9 +534,11 @@ class PaimonDatasetReader(ABC):
                 if key in visual_windows:
                     item[key] = visual_windows[key][offset]
                 else:
-                    item[key] = torch.stack([
-                        converted[position][key] for position in positions
-                    ])
+                    values = [converted[position][key] for position in 
positions]
+                    if key == "subtask_index" and _contains_none(values):
+                        item[key] = values
+                    else:
+                        item[key] = torch.stack(values)
             item.update(plan["padding"])
             if self.image_transforms is not None:
                 for key in self._visual_keys:
@@ -544,6 +546,7 @@ class PaimonDatasetReader(ABC):
             result.append(item)
         if return_batch:
             return _collate_lerobot_batch(result, video_windows)
+        _pack_nullable_labels(result)
         return result
 
     def __getitem__(self, index):
@@ -1147,8 +1150,10 @@ def _build_frame_validation_context(
 
 
 def _index_names(values, index_field):
-    if values is None or len(values) == 0:
+    if values is None:
         return None
+    if len(values) == 0:
+        return {}
     if not hasattr(values, "iterrows"):
         return {
             index: str(value) for index, value in enumerate(values)
@@ -1412,11 +1417,16 @@ def _validate_control_row(index, row, 
validation_context, tolerance_s):
             % (index, episode))
     subtasks = validation_context["subtask_names"]
     if subtasks is not None:
-        subtask = _control_index(row, "subtask_index", index)
-        if subtask not in subtasks:
+        if "subtask_index" not in row:
             raise ValueError(
-                "Paimon subtask_index at LeRobot index %d is absent from "
-                "metadata: %r." % (index, subtask))
+                "Paimon subtask_index at LeRobot index %d is missing."
+                % index)
+        if row["subtask_index"] is not None:
+            subtask = _control_index(row, "subtask_index", index)
+            if subtask not in subtasks:
+                raise ValueError(
+                    "Paimon subtask_index at LeRobot index %d is absent from "
+                    "metadata: %r." % (index, subtask))
 
 
 def _control_index(row, name, index):
@@ -1490,8 +1500,9 @@ def _attach_task_labels(rows, task_names, subtask_names):
         task_index = operator.index(row["task_index"])
         row["task"] = task_names[task_index]
         if subtask_names is not None:
-            subtask_index = operator.index(row["subtask_index"])
-            row["subtask"] = subtask_names[subtask_index]
+            subtask_index = row["subtask_index"]
+            row["subtask"] = (None if subtask_index is None
+                              else 
subtask_names[operator.index(subtask_index)])
 
 
 def _decode_video_windows(
@@ -1675,20 +1686,69 @@ def _decode_video_windows_with_pool(
     return {key: windows for key, windows in decoded if windows is not None}
 
 
+def _pack_nullable_labels(rows):
+    import torch
+
+    labels = [row.get("subtask_index") for row in rows]
+    if not any(_contains_none(value) for value in labels):
+        return
+    tensors = [value for label in labels
+               for value in (label if isinstance(label, list) else [label])
+               if torch.is_tensor(value)]
+    if not tensors:
+        return
+    # Disjoint views preserve isolation while sharing one storage across IPC.
+    packed = torch.cat([value.reshape(-1) for value in tensors])
+    views = iter(packed.split([value.numel() for value in tensors]))
+    for row, label in zip(rows, labels):
+        if isinstance(label, list):
+            row["subtask_index"] = [
+                next(views).reshape(value.shape) if torch.is_tensor(value) 
else value
+                for value in label]
+        elif torch.is_tensor(label):
+            row["subtask_index"] = next(views).reshape(label.shape)
+
+
 def _collate_lerobot_batch(rows, video_windows):
+    import torch
     from torch.utils.data import default_collate
 
-    if not video_windows:
+    nullable = {}
+    if "subtask_index" in rows[0]:
+        labels = [row["subtask_index"] for row in rows]
+        if any(_contains_none(value) for value in labels):
+            def values(label):
+                if isinstance(label, list):
+                    return [values(value) for value in label]
+                return -1 if label is None else label.tolist()
+
+            nullable["subtask_index"] = torch.tensor(
+                [values(label) for label in labels], dtype=torch.int64, 
device="cpu")
+            nullable["subtask_index_is_valid"] = nullable["subtask_index"] >= 0
+        else:
+            nullable["subtask_index"] = default_collate(labels)
+            nullable["subtask_index_is_valid"] = torch.ones_like(
+                nullable["subtask_index"], dtype=torch.bool)
+    if "subtask" in rows[0] and any(_contains_none(row["subtask"]) for row in 
rows):
+        nullable["subtask"] = [row["subtask"] for row in rows]
+    if not video_windows and not nullable:
         return default_collate(rows)
     remaining = [{
         key: value for key, value in row.items()
-        if key not in video_windows
+        if key not in video_windows and key not in nullable
     } for row in rows]
     batch = default_collate(remaining)
+    batch.update(nullable)
     batch.update(video_windows)
     return batch
 
 
+def _contains_none(value):
+    if isinstance(value, (list, tuple)):
+        return any(_contains_none(item) for item in value)
+    return value is None
+
+
 def _stack_visual_windows(plans, rows, visual_keys):
     import torch
 
@@ -1725,7 +1785,8 @@ def _torch_row(row, features, return_uint8=False):
         elif feature.get("dtype") == "video":
             result[key] = _video_tensor(
                 value, feature, return_uint8=return_uint8)
-        elif feature.get("dtype") != "string" and not torch.is_tensor(value):
+        elif value is not None and feature.get("dtype") != "string" \
+                and not torch.is_tensor(value):
             dtype = getattr(torch, _TORCH_DTYPE_NAMES[feature.get("dtype")])
             result[key] = torch.tensor(value, dtype=dtype)
     return result
diff --git a/paimon-python/pypaimon/multimodal/lerobot/loader.py 
b/paimon-python/pypaimon/multimodal/lerobot/loader.py
index 9a7af6d5ef..5060456d99 100644
--- a/paimon-python/pypaimon/multimodal/lerobot/loader.py
+++ b/paimon-python/pypaimon/multimodal/lerobot/loader.py
@@ -332,6 +332,8 @@ def _validate_frame_controls(
                    sorted(allowed_tasks)))
         seen_tasks.add(task_index)
         if subtask_indices is not None:
+            if values["subtask_index"][offset] is None:
+                continue
             subtask_index = _control_integer(
                 values["subtask_index"][offset], "subtask_index", index)
             if subtask_index not in subtask_indices:
diff --git a/paimon-python/pypaimon/multimodal/lerobot/metadata.py 
b/paimon-python/pypaimon/multimodal/lerobot/metadata.py
index b4fc38a7b4..e2d57dfa7f 100644
--- a/paimon-python/pypaimon/multimodal/lerobot/metadata.py
+++ b/paimon-python/pypaimon/multimodal/lerobot/metadata.py
@@ -285,7 +285,8 @@ def _commit_metadata(
     for name in ("tasks", "subtasks", "stats", "info"):
         if name not in tables:
             continue
-        snapshot_id = _append_arrow(tables[name], metadata[name + "_table"])
+        snapshot_id = _append_arrow(tables[name], metadata[name + "_table"],
+                                    allow_empty=name == "subtasks")
         _require_initial_snapshot(name, snapshot_id)
         component_snapshots.append((tables[name].identifier, snapshot_id))
     frames_table = connection.catalog.get_table(frames_identifier)
@@ -360,8 +361,8 @@ def _require_initial_snapshot(component, snapshot_id):
             "expected snapshot 1, found %d." % (component, snapshot_id))
 
 
-def _append_arrow(table, data):
-    return _append_arrow_tables(table, [data])
+def _append_arrow(table, data, allow_empty=False):
+    return _append_arrow_tables(table, [data], allow_empty=allow_empty)
 
 
 def _overwrite_arrow(table, data):
@@ -390,7 +391,9 @@ def _overwrite_arrow(table, data):
             table_commit.close()
 
 
-def _append_arrow_tables(table, tables):
+def _append_arrow_tables(table, tables, allow_empty=False):
+    if allow_empty:
+        table = table.copy({"snapshot.ignore-empty-commit": "false"})
     builder = table.new_batch_write_builder()
     table_write = None
     table_commit = None
@@ -412,7 +415,7 @@ def _append_arrow_tables(table, tables):
             table_write.write_arrow(data)
             row_count += data.num_rows
             del data
-        if row_count == 0:
+        if row_count == 0 and not allow_empty:
             table_write.abort()
             return None
         messages = table_write.prepare_commit()
diff --git a/paimon-python/pypaimon/multimodal/lerobot/schema.py 
b/paimon-python/pypaimon/multimodal/lerobot/schema.py
index af47f4c543..8071a5b14f 100644
--- a/paimon-python/pypaimon/multimodal/lerobot/schema.py
+++ b/paimon-python/pypaimon/multimodal/lerobot/schema.py
@@ -157,7 +157,7 @@ def _feature_field(name, feature, legacy_vectors=False):
     return pa.field(
         name,
         arrow_type,
-        nullable=False,
+        nullable=name == "subtask_index",
         metadata={b"description": description.encode("utf-8")},
     )
 
diff --git a/paimon-python/pypaimon/tests/multimodal_lerobot_test.py 
b/paimon-python/pypaimon/tests/multimodal_lerobot_test.py
index c383a8e92b..9fb7a9a516 100644
--- a/paimon-python/pypaimon/tests/multimodal_lerobot_test.py
+++ b/paimon-python/pypaimon/tests/multimodal_lerobot_test.py
@@ -118,6 +118,16 @@ class _ManualDatasetReader(pmm.PaimonDatasetReader):
         raise NotImplementedError
 
 
+class _NullableLabelReader(pmm.PaimonDatasetReader):
+
+    def read_indices(self, indices, columns):
+        return pa.Table.from_pylist([
+            {"index": i, "episode_index": 0, "frame_index": i,
+             "timestamp": i / 10.0, "task_index": 0,
+             "subtask_index": None if i % 16 == 15 else 0}
+            for i in indices], schema=self.schema).select(columns)
+
+
 class _PickleDatasetReader(_ManualDatasetReader):
 
     def __init__(self, value):
@@ -1046,6 +1056,142 @@ class LeRobotValidationTest(unittest.TestCase):
                     with self.assertRaisesRegex(ValueError, option):
                         pmm.PaimonLeRobotDataset(Mock())
 
+    def test_nullable_windows_share_one_storage_across_workers(self):
+        try:
+            import torch
+        except ImportError as error:
+            self.skipTest(str(error))
+        metadata = {
+            "info": {
+                "codebase_version": "v3.0", "fps": 10,
+                "total_frames": 128, "total_episodes": 1, "total_tasks": 1,
+                "features": {
+                    key: {"dtype": dtype, "shape": [1]}
+                    for key, dtype in (("index", "int64"), ("episode_index", 
"int64"),
+                                       ("frame_index", "int64"), ("timestamp", 
"float32"),
+                                       ("task_index", "int64"), 
("subtask_index", "int64"))
+                },
+            },
+            "tasks": ["pick"], "subtasks": ["reach"],
+            "episodes": [{"episode_index": 0, "dataset_from_index": 0,
+                          "dataset_to_index": 128, "length": 128, "tasks": 
["pick"]}],
+        }
+        reader = _NullableLabelReader(
+            metadata, delta_timestamps={"subtask_index": [i / 10.0 for i in 
range(-1, 31)]})
+        dataset = pmm.PaimonLeRobotDataset(reader)
+        try:
+            samples = dataset.get_items([0, 0])
+            samples[0]["subtask_index"][0].fill_(-100)
+            self.assertEqual(0, samples[0]["subtask_index"][1].item())
+            self.assertEqual(0, samples[1]["subtask_index"][0].item())
+            loader = dataset.to_dataloader(
+                batch_size=64, num_workers=1, multiprocessing_context="spawn")
+            for batch in loader:
+                labels = batch["subtask_index"]
+                mask = batch["subtask_index_is_valid"]
+                self.assertTrue(labels.is_shared())
+                self.assertTrue(mask.is_shared())
+                self.assertEqual((64, 32), tuple(labels.shape))
+                self.assertEqual(labels.shape, mask.shape)
+                self.assertEqual(torch.int64, labels.dtype)
+                self.assertEqual(torch.bool, mask.dtype)
+                for offset, index in enumerate(batch["index"].tolist()):
+                    for column, delta in enumerate(range(-1, 31)):
+                        position = min(127, max(0, index + delta))
+                        expected = position % 16 != 15
+                        self.assertEqual(expected, mask[offset, column].item())
+                        self.assertEqual(0 if expected else -1, labels[offset, 
column].item())
+                before = labels.clone()
+                labels[0, 0] = -100
+                self.assertTrue(torch.equal(before.flatten()[1:], 
labels.flatten()[1:]))
+        finally:
+            dataset.close()
+
+    def test_nullable_batch_contract_is_stable(self):
+        import pytest
+        torch = pytest.importorskip("torch")
+        from pypaimon.multimodal.lerobot.dataset import _collate_lerobot_batch
+
+        for labels, expected, validity in (
+                ([torch.tensor(0), None], [0, -1], [True, False]),
+                ([torch.tensor(0), torch.tensor(1)], [0, 1], [True, True]),
+                ([None, None], [-1, -1], [False, False]),
+                ([[None, torch.tensor(1)], torch.tensor([2, 3])],
+                 [[-1, 1], [2, 3]], [[False, True], [True, True]])):
+            batch = _collate_lerobot_batch([{"subtask_index": label} for label 
in labels], {})
+            self.assertEqual(expected, batch["subtask_index"].tolist())
+            self.assertEqual(validity, 
batch["subtask_index_is_valid"].tolist())
+            self.assertEqual(torch.int64, batch["subtask_index"].dtype)
+            self.assertEqual(torch.bool, batch["subtask_index_is_valid"].dtype)
+
+    def test_nullable_label_storage_preserves_mixed_shapes(self):
+        try:
+            import torch
+        except ImportError as error:
+            self.skipTest(str(error))
+        from pypaimon.multimodal.lerobot.dataset import _pack_nullable_labels
+
+        scalar = torch.tensor(3)
+        rows = [{"subtask_index": [scalar, scalar, None]},
+                {"subtask_index": torch.tensor([4, 5, 6])},
+                {"subtask_index": scalar}, {"subtask_index": None}]
+        _pack_nullable_labels(rows)
+        first = rows[0]["subtask_index"]
+        self.assertIsNone(first[2])
+        self.assertIsNone(rows[3]["subtask_index"])
+        tensors = first[:2] + [rows[1]["subtask_index"], 
rows[2]["subtask_index"]]
+        self.assertEqual(1, len({value.untyped_storage().data_ptr() for value 
in tensors}))
+        first[0].fill_(-100)
+        self.assertEqual(3, first[1].item())
+        self.assertEqual(3, rows[2]["subtask_index"].item())
+        self.assertEqual([4, 5, 6], rows[1]["subtask_index"].tolist())
+        self.assertEqual(3, scalar.item())
+        valid = [{"subtask_index": scalar}]
+        _pack_nullable_labels(valid)
+        self.assertIs(scalar, valid[0]["subtask_index"])
+        empty = [{"subtask_index": [None, None]}]
+        _pack_nullable_labels(empty)
+        self.assertEqual([None, None], empty[0]["subtask_index"])
+
+    def test_custom_reader_empty_subtask_vocabulary(self):
+        try:
+            import torch  # noqa: F401
+        except ImportError as error:
+            self.skipTest(str(error))
+        metadata = {
+            "info": {
+                "codebase_version": "v3.0", "fps": 10,
+                "total_frames": 1, "total_episodes": 1, "total_tasks": 1,
+                "features": {
+                    key: {"dtype": dtype, "shape": [1]}
+                    for key, dtype in (("index", "int64"), ("episode_index", 
"int64"),
+                                       ("frame_index", "int64"), ("timestamp", 
"float32"),
+                                       ("task_index", "int64"), 
("subtask_index", "int64"))
+                },
+            },
+            "tasks": ["pick"], "subtasks": [],
+            "episodes": [{"episode_index": 0, "dataset_from_index": 0,
+                          "dataset_to_index": 1, "length": 1, "tasks": 
["pick"]}],
+        }
+
+        class Reader(pmm.PaimonDatasetReader):
+            label = None
+
+            def read_indices(self, indices, columns):
+                return pa.Table.from_pylist([
+                    {"index": 0, "episode_index": 0, "frame_index": 0,
+                     "timestamp": 0.0, "task_index": 0, "subtask_index": 
self.label}
+                    for unused in indices], schema=self.schema).select(columns)
+
+        reader = Reader(metadata)
+        self.assertIsNone(reader[0]["subtask"])
+        batch = next(iter(pmm.PaimonLeRobotDataset(reader).to_dataloader(
+            batch_size=1, num_workers=0)))
+        self.assertEqual([None], batch["subtask"])
+        reader.label = 0
+        with self.assertRaises(ValueError):
+            reader[0]
+
     def test_video_batches_include_delta_frames_and_preserve_backends(self):
         try:
             import torch
@@ -2349,6 +2495,13 @@ class LeRobotValidationTest(unittest.TestCase):
             _validate_frame_controls(
                 batch, 30, 0, 0, 0, [0], range(2))
 
+        nullable = batch.set_column(
+            batch.schema.get_field_index("subtask_index"),
+            "subtask_index", pa.array([None], type=pa.int64()))
+        self.assertEqual(
+            {0}, _validate_frame_controls(
+                nullable, 30, 0, 0, 0, [0], range(2)))
+
     def test_metadata_writer_closes_after_commit_creation_failure(self):
         table = Mock()
         builder = table.new_batch_write_builder.return_value
@@ -4305,6 +4458,39 @@ class LeRobotImportTest(unittest.TestCase):
                 self.assertEqual("reach", row["subtask"])
                 self.assertEqual(info["total_frames"], len(dataset))
 
+    def test_import_empty_subtask_vocabulary(self):
+        import pandas as pd
+
+        source = self.temp_dir / "empty_subtasks"
+        shutil.copytree(self.image_source, source)
+        info_path = source / "meta/info.json"
+        info = json.loads(info_path.read_text())
+        info["features"]["subtask_index"] = {
+            "dtype": "int64", "shape": [1], "names": None}
+        info_path.write_text(json.dumps(info))
+        for path in (source / "data").rglob("*.parquet"):
+            data = pq.read_table(path)
+            pq.write_table(data.append_column(
+                "subtask_index", pa.nulls(data.num_rows, type=pa.int64())), 
path)
+        vocabulary = pa.Table.from_pandas(pd.DataFrame(
+            {"subtask_index": [0]},
+            index=pd.Index(["reach"], name="instruction"))).slice(0, 0)
+        pq.write_table(vocabulary, source / "meta/subtasks.parquet")
+        self.connection.load_from_lerobot("empty_subtasks", source, 
tag_name="train")
+        table, stored = _catalog_arrow(self.connection, 
"empty_subtasks__subtasks")
+        self.assertEqual(0, stored.num_rows)
+        self.assertTrue(_target_schema(table).equals(vocabulary.schema, 
check_metadata=False))
+        self.assertEqual(1, self.connection.catalog.get_tag(
+            self.connection._identifier("empty_subtasks__subtasks"), 
"train").snapshot.id)
+        dataset = pmm.PaimonLeRobotDataset(
+            self.connection.get_table("empty_subtasks"), tag_name="train")
+        self.assertIsNone(dataset[0]["subtask"])
+        self.assertIsNone(dataset[0]["subtask_index"])
+        batch = next(iter(dataset.to_dataloader(batch_size=5, num_workers=0)))
+        self.assertEqual([None] * 5, batch["subtask"])
+        self.assertEqual([-1] * 5, batch["subtask_index"].tolist())
+        self.assertFalse(batch["subtask_index_is_valid"].any())
+
     def test_import_publishes_optional_subtasks(self):
         import pandas as pd
 
@@ -4327,6 +4513,8 @@ class LeRobotImportTest(unittest.TestCase):
                 for index in range(data.num_rows)
             ]
             next_subtask += data.num_rows
+            if next_subtask == 5:
+                values[-1] = None
             pq.write_table(data.append_column(
                 "subtask_index",
                 pa.array(values, type=pa.int64()),
@@ -4344,7 +4532,7 @@ class LeRobotImportTest(unittest.TestCase):
         self.assertNotIn("subtask", [
             field.name for field in frames.raw_table.fields
         ])
-        self.assertEqual([0, 1, 0, 1, 0], frames.scan().select([
+        self.assertEqual([0, 1, 0, 1, None], frames.scan().select([
             "index", "subtask_index"
         ]).to_arrow().sort_by("index").column("subtask_index").to_pylist())
         subtasks_table = self.connection.catalog.get_table(
@@ -4367,6 +4555,43 @@ class LeRobotImportTest(unittest.TestCase):
         self.assertEqual(["reach", "grasp"], list(
             dataset.meta.subtasks.index))
         self.assertEqual("reach", dataset[0]["subtask"])
+        self.assertIsNone(dataset[4]["subtask_index"])
+        self.assertIsNone(dataset[4]["subtask"])
+        self.assertEqual(["grasp", None], [
+            row["subtask"] for row in dataset.__getitems__([3, 4])
+        ])
+        batch = next(iter(dataset.to_dataloader(
+            batch_size=5, shuffle=False, num_workers=0)))
+        self.assertEqual([0, 1, 2, 3, 4], batch["index"].tolist())
+        self.assertEqual([0, 1, 0, 1, -1], batch["subtask_index"].tolist())
+        self.assertEqual([True, True, True, True, False],
+                         batch["subtask_index_is_valid"].tolist())
+        self.assertEqual(["reach", "grasp", "reach", "grasp", None],
+                         batch["subtask"])
+        windowed = pmm.PaimonLeRobotDataset(
+            frames, tag_name="training",
+            delta_timestamps={"subtask_index": [-0.1, 0.0]})
+        self.assertEqual([1, None], [
+            None if value is None else int(value)
+            for value in windowed[4]["subtask_index"]
+        ])
+        padded = pmm.PaimonLeRobotDataset(
+            frames, tag_name="training",
+            delta_timestamps={"subtask_index": [-0.1, 0.0, 0.2]})
+        samples = padded.__getitems__([2, 2])
+        self.assertEqual([True, False, False],
+                         samples[0]["subtask_index_is_pad"].tolist())
+        for sample in samples:
+            self.assertEqual([0, 0, None], [
+                None if value is None else int(value)
+                for value in sample["subtask_index"]
+            ])
+        samples[0]["subtask_index"][0].fill_(-100)
+        self.assertEqual(0, int(samples[0]["subtask_index"][1]))
+        self.assertEqual([0, 0, None], [
+            None if value is None else int(value)
+            for value in samples[1]["subtask_index"]
+        ])
         self.assertEqual(
             1,
             self.connection.catalog.get_tag(

Reply via email to