Skip to content

Commit

Permalink
replace lambda assignment with def statement
Browse files Browse the repository at this point in the history
  • Loading branch information
RobBuchananCompPhys committed Feb 14, 2025
1 parent e675289 commit 5b9b5e5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions MDANSE_GUI/Src/MDANSE_GUI/InputWidgets/TrajectoryFilterWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ def edit_preferences(self, key: str, value: any) -> None:

self.render_canvas_assets()

def resample_and_normalise(self, signal, to_len):

Check failure on line 257 in MDANSE_GUI/Src/MDANSE_GUI/InputWidgets/TrajectoryFilterWidget.py

View workflow job for this annotation

GitHub Actions / lint_check_ruff_gui

Ruff (F811)

MDANSE_GUI/Src/MDANSE_GUI/InputWidgets/TrajectoryFilterWidget.py:257:38: F811 Redefinition of unused `signal` from line 20
"""
"""
return signal.resample(signal, to_len) * (signal.max() ** (-1))

def set_trajectory_power_spectrum(
self, filter: Filter
) -> Tuple[np.ndarray, np.ndarray]:
Expand All @@ -272,9 +278,6 @@ def set_trajectory_power_spectrum(
"""
response = filter.freq_response

# Lambda to resample and normalise input values
values = lambda a, new_len: signal.resample(a, new_len) * (a.max() ** (-1))

# Trajectory power spectrum data
raw_power_spectrum = copy.deepcopy(self._trajectory_power_spectrum)
raw_power_spectrum_energies, raw_power_spectrum_values = raw_power_spectrum
Expand All @@ -292,7 +295,7 @@ def set_trajectory_power_spectrum(
filter.freq_response = (filter.coeffs, Filter.FrequencyRangeMethod.CUSTOM)

# Resample and normalise trajectory power spectrum (y-axis)
ps = values(raw_power_spectrum_values, len(response.frequencies))
ps = self.resample_and_normalise(signal=raw_power_spectrum_values, to_len=len(response.frequencies))

# Compute power spectral attenuation due to filter (multiplicative)
attenuated_ps = ps * filter.freq_response.magnitudes
Expand Down

0 comments on commit 5b9b5e5

Please sign in to comment.