@@ -102,11 +102,15 @@ def test_segment_lerobot_v21_dataset(tmp_path: Path, empty_lerobot_dataset_facto
102102 assert ep0 ["frame_index" ] == [0 , 1 , 2 ]
103103 assert ep0 ["episode_index" ] == [0 , 0 , 0 ]
104104 assert ep0 ["index" ] == [0 , 1 , 2 ]
105+ assert np .isclose (float (ep0 ["timestamp" ][0 ]), 0.0 )
106+ assert np .allclose (np .diff (np .asarray (ep0 ["timestamp" ], dtype = np .float64 )), 1.0 / dataset .fps )
105107 assert [float (x ) for x in ep0 ["state" ]] == [2.0 , 3.0 , 4.0 ]
106108
107109 assert ep1 ["frame_index" ] == [0 , 1 , 2 , 3 , 4 ]
108110 assert ep1 ["episode_index" ] == [1 , 1 , 1 , 1 , 1 ]
109111 assert ep1 ["index" ] == [3 , 4 , 5 , 6 , 7 ]
112+ assert np .isclose (float (ep1 ["timestamp" ][0 ]), 0.0 )
113+ assert np .allclose (np .diff (np .asarray (ep1 ["timestamp" ], dtype = np .float64 )), 1.0 / dataset .fps )
110114 assert [float (x ) for x in ep1 ["state" ]] == [5.0 , 6.0 , 7.0 , 8.0 , 9.0 ]
111115
112116
@@ -222,6 +226,11 @@ def test_segment_lerobot_non_consecutive_and_overlapping_ranges(
222226 assert ep1 ["index" ] == list (range (10 , 15 ))
223227 assert ep2 ["index" ] == list (range (15 , 25 ))
224228
229+ # Timestamps are rebased per output episode.
230+ assert np .isclose (float (ep0 ["timestamp" ][0 ]), 0.0 )
231+ assert np .isclose (float (ep1 ["timestamp" ][0 ]), 0.0 )
232+ assert np .isclose (float (ep2 ["timestamp" ][0 ]), 0.0 )
233+
225234 # Data slices match requested source windows.
226235 assert [float (x ) for x in ep0 ["state" ]] == [float (i ) for i in range (0 , 10 )]
227236 assert [float (x ) for x in ep1 ["state" ]] == [float (i ) for i in range (18 , 23 )]
0 commit comments