Skip to content

Commit

Permalink
fixed exception when there are no tone matches passed to each tone fi…
Browse files Browse the repository at this point in the history
…nder.
  • Loading branch information
TheGreatCodeholio committed Apr 13, 2024
1 parent 042bdef commit b6f889f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"

[project]
name = "icad_tone_detection"
version = "0.5"
version = "0.7"
authors = [
{name = "TheGreatCodeholio", email = "[email protected]"},
]
description = "A Python library for extracting scanner radio tones from scanner audio."
readme = "README.md"
requires-python = ">=3.11"
requires-python = ">=3.10"
dependencies = [
"numpy~=1.26.4",
"requests~=2.31.0",
Expand Down
9 changes: 6 additions & 3 deletions src/icad_tone_detection/tone_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ def detect_quickcall(frequency_matches):
qc2_matches = []
tone_id = 0
last_set = None
if not frequency_matches or len(frequency_matches) < 1:
return qc2_matches
for x in frequency_matches:
if last_set is None and len(x[2]) >= 8 and 0 not in x[2] and 0.0 not in x[2]:
last_set = x
Expand All @@ -24,8 +26,9 @@ def detect_long_tones(frequency_matches, detected_quickcall):
long_tone_matches = []
excluded_frequencies = set([])

if not frequency_matches:
if not frequency_matches or len(frequency_matches) < 1:
return long_tone_matches

last_set = frequency_matches[0]
# add detected quick call tones to a list, so we can exclude them from long tone matches.
for ttd in detected_quickcall:
Expand Down Expand Up @@ -226,8 +229,8 @@ def detect_warble_tones(frequency_matches, interval_length, min_alternations):
sequences = []
id_index = 1

if not frequency_matches:
raise ValueError("The frequency_matches list cannot be empty.")
if not frequency_matches or len(frequency_matches) < 1:
return sequences

i = 0
while i < len(frequency_matches):
Expand Down

0 comments on commit b6f889f

Please sign in to comment.