def test_orientation_eighth_angles() -> None: """Initialize a detection and a ground truth label with only orientation parameters. Verify that calculated orientation error matches the expected smallest angle ((2 * np.pi) / 8) between the detection and ground truth label. """ expected_result: float = (2 * np.pi) / 8 eigth_angle = [ np.array([0, 0, angle]) for angle in np.arange(0, 2 * np.pi, expected_result) ] for i in range(len(eigth_angle) - 1): dts: DataFrame = DataFrame([{ "quaternion": quat_scipy2argo_vectorized( R.from_rotvec(eigth_angle[i]).as_quat()) }]) gts: DataFrame = DataFrame([{ "quaternion": quat_scipy2argo_vectorized( R.from_rotvec(eigth_angle[i + 1]).as_quat()) }]) assert np.isclose(dist_fn(dts, gts, DistFnType.ORIENTATION), expected_result) assert np.isclose(dist_fn(gts, dts, DistFnType.ORIENTATION), expected_result)
def test_scale_distance() -> None: """Initialize a detection and a ground truth label with only shape parameters (only shape parameters due to alignment assumption). Verify that calculated scale error matches the expected value. """ dts: DataFrame = DataFrame([{"width": 5, "height": 5, "length": 5}]) gts: DataFrame = DataFrame([{"width": 10, "height": 10, "length": 10}]) expected_result: float = 1 - 0.125 assert dist_fn(dts, gts, DistFnType.SCALE) == expected_result
def test_translation_distance() -> None: """Initialize a detection and a ground truth label with only translation parameters. Verify that calculated distance matches expected distance under the specified `DistFnType`. """ dts: DataFrame = DataFrame([{"translation": [0.0, 0.0, 0.0]}]) gts: DataFrame = DataFrame([{"translation": [5.0, 5.0, 5.0]}]) expected_result: float = np.sqrt(25 + 25 + 25) assert dist_fn(dts, gts, DistFnType.TRANSLATION) == expected_result