from __future__ import annotations from kitti_c2l.decalibration import sample_dual_decalibration from kitti_c2l.geometry import matrix_to_euler_deg from kitti_c2l.stages import STAGES def test_sampled_values_within_stage_bounds(): for stage in STAGES: for seed in range(10): dual = sample_dual_decalibration(seed, stage) for decal in (dual.lidar, dual.camera): assert (abs(decal.euler_deg) <= stage.max_rotation_deg + 1e-6).all() assert (abs(decal.translation_cm) <= stage.max_translation_cm + 1e-6).all() euler_from_matrix = matrix_to_euler_deg(decal.rotation) assert (abs(euler_from_matrix) <= stage.max_rotation_deg + 1e-3).all() def test_lidar_and_camera_draws_are_independent(): dual = sample_dual_decalibration(seed=42, stage=STAGES[0]) assert not (dual.lidar.euler_deg == dual.camera.euler_deg).all() assert not (dual.lidar.translation_cm == dual.camera.translation_cm).all() def test_same_seed_reproducible(): first = sample_dual_decalibration(seed=123, stage=STAGES[2]) second = sample_dual_decalibration(seed=123, stage=STAGES[2]) assert (first.lidar.euler_deg == second.lidar.euler_deg).all() assert (first.camera.translation_cm == second.camera.translation_cm).all() def test_different_seeds_differ(): a = sample_dual_decalibration(seed=1, stage=STAGES[0]) b = sample_dual_decalibration(seed=2, stage=STAGES[0]) assert not (a.lidar.euler_deg == b.lidar.euler_deg).all()