Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: simplify error handling in TimeSeriesAnalysis section #126

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions edvart/report_sections/timeseries_analysis/timeseries_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ def __init__(
enum_to_implementation[subsec.ShortTimeFT] = ShortTimeFT(
sampling_rate, stft_window_size, verbosity_short_time_ft, columns
)
elif subsections is not None and subsec.ShortTimeFT in subsections:
raise ValueError(
"Need to set an `stft_window_size` to plot Short-time Fourier transform."
)
elif subsections is not None:
if subsec.FourierTransform in subsections:
raise ValueError("Need to set a `sampling_rate` to plot Fourier transform.")
if subsec.ShortTimeFT in subsections:
raise ValueError(
"Need to set a `sampling_rate` to plot Short-time Fourier transform."
)

# By default use all subsections, FT and STFT only if required parameters specified
if subsections is None:
Expand All @@ -162,17 +173,6 @@ def __init__(
if subsections is None:
subsections_implementations = list(enum_to_implementation.values())
else:
if sampling_rate is None:
if subsec.FourierTransform in subsections:
raise ValueError("Need to set a `sampling_rate` to plot Fourier transform.")
if subsec.ShortTimeFT in subsections:
raise ValueError(
"Need to set a `sampling_rate` to plot Short-time Fourier transform."
)
if stft_window_size is None and subsec.ShortTimeFT in subsections:
raise ValueError(
"Need to set an `stft_window_size` to plot Short-time Fourier transform."
)
subsections_implementations = [enum_to_implementation[sub] for sub in subsections]

super().__init__(subsections_implementations, verbosity, columns)
Expand Down