diff --git a/.gitignore b/.gitignore index 024f9a2..ad423c1 100644 --- a/.gitignore +++ b/.gitignore @@ -102,10 +102,11 @@ experiments/* .virtual_documents .ipynb_checkpoints *.ipynb -!batdetect2_notebook.ipynb - -# Batdetect Models [Include] -!batdetect2/models/*.pth.tar # Bump2version .bumpversion.cfg + +# DO Include +!batdetect2_notebook.ipynb +!batdetect2/models/*.pth.tar +!tests/data/*.wav diff --git a/tests/data/20230322_172000_selec2.wav b/tests/data/20230322_172000_selec2.wav new file mode 100644 index 0000000..2a2c1c5 Binary files /dev/null and b/tests/data/20230322_172000_selec2.wav differ diff --git a/tests/test_detections.py b/tests/test_detections.py new file mode 100644 index 0000000..7f17012 --- /dev/null +++ b/tests/test_detections.py @@ -0,0 +1,23 @@ +"""Test suite to ensure that model detections are not incorrect.""" + +import os + +from batdetect2 import api + +DATA_DIR = os.path.join(os.path.dirname(__file__), "data") + + +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"] + )