"""Checks of evaluate.py: python test_evaluate.py (the check against the benchmark itself is `evaluate.py rules`).""" import numpy as np import evaluate instants = ["2026-10-01T00:00Z", "2026-10-01T00:15Z", "2026-10-01T00:30Z"] yhat = evaluate.events_to_yhat([{"start": "2026-10-01T00:15Z", "end": "2026-10-01T00:30Z", "category": "Obstruction"}, {"start": "2026-10-01T00:00Z", "end": "2026-10-01T00:00Z", "kind": "Visibility"}], instants) assert yhat[:, 1].tolist() == [0, 1, 1] and yhat[:, 0].tolist() == [1, 0, 0] # bounds included y = np.zeros_like(yhat) y[1:, 1] = 1 y[2, 0] = 1 c = evaluate.counts(y, yhat) assert c == {"Visibility": [1, 1, 0], "Obstruction": [2, 2, 2]}, c assert evaluate.regressions({"Obstruction": [10, 10, 5]}, {"Obstruction": [10, 4, 4]}) == [("Obstruction", "found", 50, 40)] assert evaluate.regressions({"Obstruction": [10, 10, 5]}, {"Obstruction": [10, 10, 5]}) == [] assert evaluate.regressions({"Obstruction": [0, 15, 0]}, {}) == [] # false alarms gone: not a regression print("ok")