generated from dopt-python/py311
54 lines
1.4 KiB
Python
54 lines
1.4 KiB
Python
from pathlib import Path
|
|
|
|
import numpy as np
|
|
import pytest
|
|
|
|
import dopt_sensor_anomalies.detection as detect
|
|
import dopt_sensor_anomalies.types as t
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def img_paths() -> tuple[Path, ...]:
|
|
img_folder = Path(__file__).parent / "_img"
|
|
if not img_folder.exists():
|
|
raise FileNotFoundError("img path not existing")
|
|
return tuple(img_folder.glob("*.bmp"))
|
|
|
|
|
|
def test_midpoint():
|
|
ptA = np.array([1.0, 2.0])
|
|
ptB = np.array([3.0, 4.0])
|
|
mid_x, mid_y = detect.midpoint(ptA, ptB)
|
|
assert mid_x == 2.0
|
|
assert mid_y == 3.0
|
|
|
|
|
|
@pytest.mark.new
|
|
def test_check_box_redundancy_SameBox():
|
|
box_1: t.Box = (
|
|
(64.70450592041016, 505.09185791015625),
|
|
(32.305301666259766, 162.31748962402344),
|
|
2.385944128036499,
|
|
)
|
|
box_2: t.Box = (
|
|
(64.5450592041016, 504.59185791015625),
|
|
(32.305301666259766, 163.01748962402344),
|
|
2.415944128036499,
|
|
)
|
|
assert detect.check_box_redundancy(box_1, box_2)
|
|
|
|
|
|
@pytest.mark.new
|
|
def test_check_box_redundancy_DifferentBox():
|
|
box_1: t.Box = (
|
|
(64.70450592041016, 505.09185791015625),
|
|
(32.305301666259766, 162.31748962402344),
|
|
2.385944128036499,
|
|
)
|
|
box_2: t.Box = (
|
|
(84.5450592041016, 104.59185791015625),
|
|
(31.305301666259766, 150.01748962402344),
|
|
2.35944128036499,
|
|
)
|
|
assert not detect.check_box_redundancy(box_1, box_2)
|