Download processing/common/test_convert_videos.py from OpenTSLab/MMTA-v1.0: direct link, hf CLI and curl.
- Browser
- Download file 1.47 kB
-
https://huggingface.co/datasets/OpenTSLab/MMTA-v1.0/resolve/main/processing/common/test_convert_videos.py
- Command line
-
hf download hf://datasets/OpenTSLab/MMTA-v1.0/processing/common/test_convert_videos.py
-
curl -L -o test_convert_videos.py https://huggingface.co/datasets/OpenTSLab/MMTA-v1.0/resolve/main/processing/common/test_convert_videos.py
1.47 kB
| #!/usr/bin/env python3 | |
| """Regression tests for distinguishing observed sensor rows from instructions.""" | |
| import unittest | |
| from convert_videos import parse_timeseries_block, parse_timeseries_data_line | |
| class SensorRowTests(unittest.TestCase): | |
| def test_format_example_is_not_an_observation(self) -> None: | |
| self.assertIsNone(parse_timeseries_data_line("t(s): speed=, acceleration=, steering=")) | |
| def test_instruction_with_commas_is_not_an_observation(self) -> None: | |
| self.assertIsNone(parse_timeseries_data_line("Per-frame sensor data, missing = unavailable:")) | |
| def test_actual_missing_observations_are_preserved(self) -> None: | |
| row = parse_timeseries_data_line("1.5: speed=10, acceleration=null") | |
| self.assertEqual(row["speed"], 10) | |
| self.assertNotEqual(row["acceleration"], row["acceleration"]) | |
| def test_iso_timestamp_rows_are_still_supported(self) -> None: | |
| self.assertEqual(parse_timeseries_data_line("2024-06-30T12:00:00Z, speed=10"), {"speed": 10}) | |
| def test_template_line_does_not_increase_sequence_length(self) -> None: | |
| frame = parse_timeseries_block( | |
| "<timeseries>\nOne-line format example:\nt(s): speed=, acceleration=\n" | |
| "1.0: speed=10, acceleration=null\n1.5: speed=9, acceleration=-1\n</timeseries>" | |
| ) | |
| self.assertEqual(frame.shape, (2, 2)) | |
| self.assertEqual(frame["speed"].tolist(), [10, 9]) | |
| if __name__ == "__main__": | |
| unittest.main() | |