pis-spatial-intelligence-lab / tests /test_lab_core.py
pedroivospatial's picture
Add private static synthetic depth review build
573b479 verified
Raw History Blame Contribute Delete
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()