You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.1 KiB
Python
82 lines
2.1 KiB
Python
from pathlib import Path
|
|
import sys
|
|
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
|
if str(PROJECT_ROOT) not in sys.path:
|
|
sys.path.insert(0, str(PROJECT_ROOT))
|
|
|
|
from track_score_policy import initial_candidate_score, required_track_score, track_passes_score_gate
|
|
|
|
|
|
def test_required_track_score_is_stricter_for_switch_than_for_acquire():
|
|
acquire_floor = required_track_score(
|
|
confirmed=False,
|
|
is_switch_candidate=False,
|
|
weak_reacq_guard=False,
|
|
)
|
|
switch_floor = required_track_score(
|
|
confirmed=True,
|
|
is_switch_candidate=True,
|
|
weak_reacq_guard=False,
|
|
)
|
|
|
|
assert switch_floor > acquire_floor
|
|
|
|
|
|
def test_weak_reacquire_uses_reacquire_floor():
|
|
reacquire_floor = required_track_score(
|
|
confirmed=True,
|
|
is_switch_candidate=False,
|
|
weak_reacq_guard=True,
|
|
)
|
|
|
|
assert track_passes_score_gate(
|
|
track_score=reacquire_floor,
|
|
confirmed=True,
|
|
is_switch_candidate=False,
|
|
weak_reacq_guard=True,
|
|
)
|
|
assert not track_passes_score_gate(
|
|
track_score=reacquire_floor - 0.01,
|
|
confirmed=True,
|
|
is_switch_candidate=False,
|
|
weak_reacq_guard=True,
|
|
)
|
|
|
|
|
|
def test_switch_candidate_must_clear_switch_floor():
|
|
switch_floor = required_track_score(
|
|
confirmed=True,
|
|
is_switch_candidate=True,
|
|
weak_reacq_guard=False,
|
|
)
|
|
|
|
assert track_passes_score_gate(
|
|
track_score=switch_floor,
|
|
confirmed=True,
|
|
is_switch_candidate=True,
|
|
weak_reacq_guard=False,
|
|
)
|
|
assert not track_passes_score_gate(
|
|
track_score=switch_floor - 0.01,
|
|
confirmed=True,
|
|
is_switch_candidate=True,
|
|
weak_reacq_guard=False,
|
|
)
|
|
|
|
|
|
def test_initial_selection_prefers_persistent_moving_target():
|
|
distant_target = initial_candidate_score(
|
|
track_score=0.06,
|
|
track_hits=6,
|
|
residual_motion=True,
|
|
)
|
|
one_frame_false_positive = initial_candidate_score(
|
|
track_score=0.14,
|
|
track_hits=1,
|
|
residual_motion=False,
|
|
)
|
|
|
|
assert distant_target > one_frame_false_positive
|