Skip to content

Commit

Permalink
fix: CLI now reads time_expansion_factor correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
mbsantiago committed May 1, 2023
1 parent 54d8321 commit b71cb8c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions batdetect2/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def detect(
audio_dir: str,
ann_dir: str,
detection_threshold: float,
time_expansion_factor: int,
**args,
):
"""Detect bat calls in files in AUDIO_DIR and save predictions to ANN_DIR.
Expand All @@ -103,6 +104,7 @@ def detect(
**{
**params,
**args,
'time_expansion': time_expansion_factor,
"spec_slices": False,
"chunk_size": 2,
"detection_threshold": detection_threshold,
Expand Down
25 changes: 25 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,28 @@ def test_cli_detect_command_on_test_audio(tmp_path):
assert results_dir.exists()
assert len(list(results_dir.glob("*.csv"))) == 3
assert len(list(results_dir.glob("*.json"))) == 3


def test_cli_detect_command_with_non_trivial_time_expansion(tmp_path):
"""Test the detect command with a non-trivial time expansion factor."""
results_dir = tmp_path / "results"

# Remove results dir if it exists
if results_dir.exists():
results_dir.rmdir()

runner = CliRunner()
result = runner.invoke(
cli,
[
"detect",
"example_data/audio",
str(results_dir),
"0.3",
"--time_expansion_factor",
"10",
],
)

assert result.exit_code == 0
assert 'time_exp_fact 10' in result.stdout

0 comments on commit b71cb8c

Please sign in to comment.