Spaces:
Paused
Paused
File size: 1,298 Bytes
1fe7075 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | """Murals hang from the wall's top edge: wall_top finds it in plane-v (no models).
python -m unittest test_wall_mural_top
"""
import os
import unittest
import numpy as np
# Same profile as the other wall tests: the first import fixes the config.
os.environ.setdefault("VISUALIZER_CONFIG", "visualizer.gpu.toml")
from services.wall.pipeline import wall_top
class WallTopTest(unittest.TestCase):
def test_v_pointing_up(self):
rows = np.repeat(np.arange(100), 50)
v = 2.4 - rows * 0.02 # higher in the image (smaller row) = larger v
top, sign = wall_top(v, rows)
self.assertEqual(sign, 1)
self.assertAlmostEqual(top, 2.4, delta=0.03)
def test_v_pointing_down(self):
rows = np.repeat(np.arange(100), 50)
v = -1.0 + rows * 0.02
top, sign = wall_top(v, rows)
self.assertEqual(sign, -1)
self.assertAlmostEqual(top, -1.0, delta=0.03)
def test_ignores_misses_and_stray_pixels(self):
rows = np.repeat(np.arange(100), 50).astype(float)
v = 2.0 - rows * 0.02
v[::97] = np.nan
v[5] = 50.0 # one stray pixel far above
top, sign = wall_top(v, rows)
self.assertEqual(sign, 1)
self.assertLess(top, 2.1)
if __name__ == "__main__":
unittest.main()
|