batdetect2/tests/test_detections.py
2026-03-29 15:55:24 +01:00

27 lines
712 B
Python

"""Test suite to ensure that model detections are not incorrect."""
import os
import pytest
from batdetect2 import api
DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
@pytest.mark.slow
def test_no_detections_above_nyquist():
"""Test that no detections are made above the nyquist frequency."""
# Recording donated by @@kdarras
path = os.path.join(DATA_DIR, "20230322_172000_selec2.wav")
# This recording has a sampling rate of 192 kHz
nyquist = 192_000 / 2
output = api.process_file(path)
predictions = output["pred_dict"]
assert len(predictions["annotation"]) != 0
assert all(
pred["high_freq"] < nyquist for pred in predictions["annotation"]
)