mirror of
https://github.com/macaodha/batdetect2.git
synced 2025-06-29 14:41:58 +02:00
tests: Added a test to check that detections above the nyquist freq are excluded
This commit is contained in:
parent
14aefafe14
commit
986cfc463c
9
.gitignore
vendored
9
.gitignore
vendored
@ -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
|
||||
|
BIN
tests/data/20230322_172000_selec2.wav
Normal file
BIN
tests/data/20230322_172000_selec2.wav
Normal file
Binary file not shown.
23
tests/test_detections.py
Normal file
23
tests/test_detections.py
Normal file
@ -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"]
|
||||
)
|
Loading…
Reference in New Issue
Block a user