Fix flake8 E501 and C901 violations in annotate.py and annotation classes
Some checks failed
Build Sphinx Docs Set / Build Docs (pull_request) Successful in 48s
Build Project / Build Project (3.12) (pull_request) Successful in 4m10s
Build Project / Build Project (3.10) (pull_request) Successful in 4m24s
Build Project / Build Project (3.11) (pull_request) Successful in 4m29s
Test with tox / Test with tox (3.11) (pull_request) Successful in 4m23s
Test with tox / Test with tox (3.10) (pull_request) Failing after 4m44s
Test with tox / Test with tox (3.12) (pull_request) Successful in 4m45s
Some checks failed
Build Sphinx Docs Set / Build Docs (pull_request) Successful in 48s
Build Project / Build Project (3.12) (pull_request) Successful in 4m10s
Build Project / Build Project (3.10) (pull_request) Successful in 4m24s
Build Project / Build Project (3.11) (pull_request) Successful in 4m29s
Test with tox / Test with tox (3.11) (pull_request) Successful in 4m23s
Test with tox / Test with tox (3.10) (pull_request) Failing after 4m44s
Test with tox / Test with tox (3.12) (pull_request) Successful in 4m45s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3b8b55ae7a
commit
f23bac08a1
|
|
@ -42,7 +42,8 @@ def annotate_with_cusum(
|
||||||
if sample_rate is None:
|
if sample_rate is None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Recording metadata does not contain 'sample_rate'. "
|
"Recording metadata does not contain 'sample_rate'. "
|
||||||
"Supply it with --sample-rate when using the CLI, or set recording.sample_rate before calling this function."
|
"Supply it with --sample-rate when using the CLI, or set "
|
||||||
|
"recording.sample_rate before calling this function."
|
||||||
)
|
)
|
||||||
center_frequency = recording.metadata.get("center_frequency", 0)
|
center_frequency = recording.metadata.get("center_frequency", 0)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,8 @@ def detect_signals_energy(
|
||||||
if sample_rate is None:
|
if sample_rate is None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Recording metadata does not contain 'sample_rate'. "
|
"Recording metadata does not contain 'sample_rate'. "
|
||||||
"Supply it with --sample-rate when using the CLI, or set recording.sample_rate before calling this function."
|
"Supply it with --sample-rate when using the CLI, or set "
|
||||||
|
"recording.sample_rate before calling this function."
|
||||||
)
|
)
|
||||||
center_frequency = recording.metadata.get("center_frequency", 0)
|
center_frequency = recording.metadata.get("center_frequency", 0)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -406,7 +406,8 @@ def split_recording_annotations(
|
||||||
if sample_rate is None:
|
if sample_rate is None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Recording metadata does not contain 'sample_rate'. "
|
"Recording metadata does not contain 'sample_rate'. "
|
||||||
"Supply it with --sample-rate when using the CLI, or set recording.sample_rate before calling this function."
|
"Supply it with --sample-rate when using the CLI, or set "
|
||||||
|
"recording.sample_rate before calling this function."
|
||||||
)
|
)
|
||||||
center_frequency = recording.metadata.get("center_frequency", 0.0)
|
center_frequency = recording.metadata.get("center_frequency", 0.0)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -221,7 +221,8 @@ def threshold_qualifier(
|
||||||
if sample_rate is None:
|
if sample_rate is None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Recording metadata does not contain 'sample_rate'. "
|
"Recording metadata does not contain 'sample_rate'. "
|
||||||
"Supply it with --sample-rate when using the CLI, or set recording.sample_rate before calling this function."
|
"Supply it with --sample-rate when using the CLI, or set "
|
||||||
|
"recording.sample_rate before calling this function."
|
||||||
)
|
)
|
||||||
center_frequency = recording.metadata.get("center_frequency", 0)
|
center_frequency = recording.metadata.get("center_frequency", 0)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -501,7 +501,10 @@ def clear(input, output, overwrite, force, quiet):
|
||||||
default="standalone",
|
default="standalone",
|
||||||
help="Annotation type",
|
help="Annotation type",
|
||||||
)
|
)
|
||||||
@click.option("--sample-rate", type=float, default=None, help="Sample rate in Hz (overrides metadata; required if not in file)")
|
@click.option(
|
||||||
|
"--sample-rate", type=float, default=None,
|
||||||
|
help="Sample rate in Hz (overrides metadata; required if not in file)"
|
||||||
|
)
|
||||||
@click.option("--output", "-o", type=click.Path(), help="Output file path")
|
@click.option("--output", "-o", type=click.Path(), help="Output file path")
|
||||||
@click.option("--overwrite", is_flag=True, help="Overwrite input file (non-SigMF only)")
|
@click.option("--overwrite", is_flag=True, help="Overwrite input file (non-SigMF only)")
|
||||||
@click.option("--quiet", is_flag=True, help="Quiet mode")
|
@click.option("--quiet", is_flag=True, help="Quiet mode")
|
||||||
|
|
@ -613,7 +616,10 @@ def energy(
|
||||||
default="standalone",
|
default="standalone",
|
||||||
help="Annotation type",
|
help="Annotation type",
|
||||||
)
|
)
|
||||||
@click.option("--sample-rate", type=float, default=None, help="Sample rate in Hz (overrides metadata; required if not in file)")
|
@click.option(
|
||||||
|
"--sample-rate", type=float, default=None,
|
||||||
|
help="Sample rate in Hz (overrides metadata; required if not in file)"
|
||||||
|
)
|
||||||
@click.option("--output", "-o", type=click.Path(), help="Output file path")
|
@click.option("--output", "-o", type=click.Path(), help="Output file path")
|
||||||
@click.option("--overwrite", is_flag=True, help="Overwrite input file (non-SigMF only)")
|
@click.option("--overwrite", is_flag=True, help="Overwrite input file (non-SigMF only)")
|
||||||
@click.option("--quiet", is_flag=True, help="Quiet mode")
|
@click.option("--quiet", is_flag=True, help="Quiet mode")
|
||||||
|
|
@ -700,7 +706,10 @@ def cusum(input, label, min_duration, window_size, tolerance, annotation_type, s
|
||||||
help="Annotation type",
|
help="Annotation type",
|
||||||
)
|
)
|
||||||
@click.option("--channel", type=int, default=0, help="Channel index to annotate (default: 0)")
|
@click.option("--channel", type=int, default=0, help="Channel index to annotate (default: 0)")
|
||||||
@click.option("--sample-rate", type=float, default=None, help="Sample rate in Hz (overrides metadata; required if not in file)")
|
@click.option(
|
||||||
|
"--sample-rate", type=float, default=None,
|
||||||
|
help="Sample rate in Hz (overrides metadata; required if not in file)"
|
||||||
|
)
|
||||||
@click.option("--output", "-o", type=click.Path(), help="Output file path")
|
@click.option("--output", "-o", type=click.Path(), help="Output file path")
|
||||||
@click.option("--overwrite", is_flag=True, help="Overwrite input file (non-SigMF only)")
|
@click.option("--overwrite", is_flag=True, help="Overwrite input file (non-SigMF only)")
|
||||||
@click.option("--quiet", is_flag=True, help="Quiet mode")
|
@click.option("--quiet", is_flag=True, help="Quiet mode")
|
||||||
|
|
@ -777,11 +786,28 @@ def threshold(input, threshold, label, window_size, annotation_type, channel, sa
|
||||||
@click.option("--nfft", type=int, default=65536, help="FFT size for spectral analysis")
|
@click.option("--nfft", type=int, default=65536, help="FFT size for spectral analysis")
|
||||||
@click.option("--noise-threshold-db", type=float, help="Noise floor threshold in dB (auto-estimated if not specified)")
|
@click.option("--noise-threshold-db", type=float, help="Noise floor threshold in dB (auto-estimated if not specified)")
|
||||||
@click.option("--min-component-bw", type=float, default=50e3, help="Min component bandwidth in Hz")
|
@click.option("--min-component-bw", type=float, default=50e3, help="Min component bandwidth in Hz")
|
||||||
@click.option("--sample-rate", type=float, default=None, help="Sample rate in Hz (overrides metadata; required if not in file)")
|
@click.option(
|
||||||
|
"--sample-rate", type=float, default=None,
|
||||||
|
help="Sample rate in Hz (overrides metadata; required if not in file)"
|
||||||
|
)
|
||||||
@click.option("--output", "-o", type=click.Path(), help="Output file path")
|
@click.option("--output", "-o", type=click.Path(), help="Output file path")
|
||||||
@click.option("--overwrite", is_flag=True, help="Overwrite input file (non-SigMF only)")
|
@click.option("--overwrite", is_flag=True, help="Overwrite input file (non-SigMF only)")
|
||||||
@click.option("--quiet", is_flag=True, help="Quiet mode")
|
@click.option("--quiet", is_flag=True, help="Quiet mode")
|
||||||
@click.option("--verbose", is_flag=True, help="Verbose output (show detected components)")
|
@click.option("--verbose", is_flag=True, help="Verbose output (show detected components)")
|
||||||
|
def _log_separate_start(quiet, recording, indices_list, nfft, noise_threshold_db, min_component_bw):
|
||||||
|
if not quiet:
|
||||||
|
click.echo("\nSplitting annotations by frequency components...")
|
||||||
|
click.echo(f" Input annotations: {len(recording.annotations)}")
|
||||||
|
if indices_list:
|
||||||
|
click.echo(f" Splitting indices: {indices_list}")
|
||||||
|
click.echo(f" FFT size: {nfft}")
|
||||||
|
if noise_threshold_db is not None:
|
||||||
|
click.echo(f" Noise threshold: {noise_threshold_db} dB")
|
||||||
|
else:
|
||||||
|
click.echo(" Noise threshold: auto-estimated")
|
||||||
|
click.echo(f" Min component BW: {format_frequency(min_component_bw)}")
|
||||||
|
|
||||||
|
|
||||||
def separate(
|
def separate(
|
||||||
input, indices, nfft, noise_threshold_db, min_component_bw, sample_rate, output, overwrite, quiet, verbose):
|
input, indices, nfft, noise_threshold_db, min_component_bw, sample_rate, output, overwrite, quiet, verbose):
|
||||||
"""
|
"""
|
||||||
|
|
@ -835,17 +861,7 @@ def separate(
|
||||||
click.echo("No annotations to split")
|
click.echo("No annotations to split")
|
||||||
return
|
return
|
||||||
|
|
||||||
if not quiet:
|
_log_separate_start(quiet, recording, indices_list, nfft, noise_threshold_db, min_component_bw)
|
||||||
click.echo("\nSplitting annotations by frequency components...")
|
|
||||||
click.echo(f" Input annotations: {len(recording.annotations)}")
|
|
||||||
if indices_list:
|
|
||||||
click.echo(f" Splitting indices: {indices_list}")
|
|
||||||
click.echo(f" FFT size: {nfft}")
|
|
||||||
if noise_threshold_db is not None:
|
|
||||||
click.echo(f" Noise threshold: {noise_threshold_db} dB")
|
|
||||||
else:
|
|
||||||
click.echo(" Noise threshold: auto-estimated")
|
|
||||||
click.echo(f" Min component BW: {format_frequency(min_component_bw)}")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
initial_count = len(recording.annotations)
|
initial_count = len(recording.annotations)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user