Download tests/test_lab_core.py from pedroivospatial/pis-spatial-intelligence-lab: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/spaces/pedroivospatial/pis-spatial-intelligence-lab/resolve/main/tests/test_lab_core.py
- Command line
-
hf download hf://spaces/pedroivospatial/pis-spatial-intelligence-lab/tests/test_lab_core.py
-
curl -L -o test_lab_core.py https://huggingface.co/spaces/pedroivospatial/pis-spatial-intelligence-lab/resolve/main/tests/test_lab_core.py
1.23 kB
| import unittest | |
| import numpy as np | |
| from PIL import Image | |
| from lab_core import SAMPLE_LABELS, analyze_depth_signal, colorize_depth, generate_scene | |
| class LabCoreTests(unittest.TestCase): | |
| def test_all_synthetic_scenes_are_deterministic_rgb(self): | |
| for key in SAMPLE_LABELS.values(): | |
| first = generate_scene(key, 320, 200) | |
| second = generate_scene(key, 320, 200) | |
| self.assertEqual(first.mode, "RGB") | |
| self.assertEqual(first.size, (320, 200)) | |
| self.assertEqual(first.tobytes(), second.tobytes()) | |
| def test_unknown_scene_is_rejected(self): | |
| with self.assertRaises(ValueError): | |
| generate_scene("real-client-site") | |
| def test_depth_colorization_and_report(self): | |
| gradient = np.tile(np.arange(64, dtype=np.uint8), (40, 1)) | |
| depth = Image.fromarray(gradient, mode="L") | |
| preview = colorize_depth(depth) | |
| report = analyze_depth_signal(depth, "Synthetic test", "model/test") | |
| self.assertEqual(preview.mode, "RGB") | |
| self.assertEqual(preview.size, depth.size) | |
| self.assertIn("Synthetic test", report) | |
| self.assertIn("not accuracy", report) | |
| if __name__ == "__main__": | |
| unittest.main() | |