Skip to content

Commit 37d61be

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent fa835bf commit 37d61be

File tree

3 files changed

+27
-23
lines changed

3 files changed

+27
-23
lines changed

mne/viz/evoked.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,14 +1896,18 @@ def plot_evoked_joint(
18961896
n_topomaps = 3 + 1
18971897
elif isinstance(times, dict) and "peaks" in times:
18981898
if len(times) != 1:
1899-
raise ValueError("If 'times' is a dict, it must have only one key 'peaks'.")
1899+
raise ValueError(
1900+
"If 'times' is a dict, it must have only one key 'peaks'."
1901+
)
19001902
val = times["peaks"]
19011903
if isinstance(val, int):
19021904
n_topomaps = val + 1
19031905
elif isinstance(val, (list, tuple)):
19041906
n_topomaps = len(val) + 1
19051907
else:
1906-
raise ValueError("Values for 'peaks' must be int or list/tuple of tuples.")
1908+
raise ValueError(
1909+
"Values for 'peaks' must be int or list/tuple of tuples."
1910+
)
19071911
else:
19081912
assert not isinstance(times, str)
19091913
n_topomaps = len(times) + 1

mne/viz/tests/test_evoked.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -669,31 +669,30 @@ def get_axes_midpoints(axes):
669669

670670
def test_plot_joint_times_dict():
671671
"""Test using a dictionary for the 'times' parameter in plot_joint."""
672-
673-
ch_names = ['F3', 'Fz', 'F4']
674-
sfreq = 1000.
675-
info = mne.create_info(ch_names=ch_names, sfreq=sfreq, ch_types='eeg')
676-
672+
ch_names = ["F3", "Fz", "F4"]
673+
sfreq = 1000.0
674+
info = mne.create_info(ch_names=ch_names, sfreq=sfreq, ch_types="eeg")
675+
677676
data = np.zeros((3, 500))
678-
679-
data[:, 100] = 5e-6
680-
data[:, 300] = 5e-6
681-
677+
678+
data[:, 100] = 5e-6
679+
data[:, 300] = 5e-6
680+
682681
evoked = mne.EvokedArray(data, info, tmin=0)
683-
684-
evoked.set_montage(mne.channels.make_standard_montage('standard_1020'))
682+
683+
evoked.set_montage(mne.channels.make_standard_montage("standard_1020"))
685684

686685
# Test 1: Integer count (Logic check: does it find N peaks?)
687686
fig = evoked.plot_joint(times={"peaks": 3}, show=False)
688-
assert len(fig.axes) >= 2
689-
687+
assert len(fig.axes) >= 2
688+
690689
# Test 2: Specific Windows (Logic check: does it parse windows?)
691690
fig2 = evoked.plot_joint(times={"peaks": [(0.0, 0.2), (0.2, 0.4)]}, show=False)
692691
assert len(fig2.axes) >= 2
693-
692+
694693
# Test 3: Validation checks (Ensuring robust error handling)
695694
with pytest.raises(ValueError, match="must be 'peaks'"):
696695
evoked.plot_joint(times={"bad_key": 5})
697696

698697
with pytest.raises(ValueError, match="Values for 'peaks' must be"):
699-
evoked.plot_joint(times={"peaks": "invalid_string"})
698+
evoked.plot_joint(times={"peaks": "invalid_string"})

mne/viz/utils.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -895,13 +895,12 @@ def _find_peaks(evoked, npeaks):
895895

896896
def _process_times(inst, use_times, n_peaks=None, few=False):
897897
"""Return a list of times for topomaps."""
898-
899898
if isinstance(use_times, dict):
900899
if "peaks" not in use_times:
901900
raise ValueError("If 'times' is a dict, the key must be 'peaks'.")
902-
901+
903902
peak_params = use_times["peaks"]
904-
903+
905904
if isinstance(peak_params, int):
906905
use_times = _find_peaks(inst, peak_params)
907906
elif isinstance(peak_params, (list, tuple)):
@@ -910,12 +909,14 @@ def _process_times(inst, use_times, n_peaks=None, few=False):
910909
if len(window) != 2:
911910
raise ValueError(f"Each window must be (tmin, tmax), got {window}")
912911
tmin, tmax = window
913-
_, t_peak = inst.get_peak(tmin=tmin, tmax=tmax, mode='abs')
912+
_, t_peak = inst.get_peak(tmin=tmin, tmax=tmax, mode="abs")
914913
peaks.append(t_peak)
915914
use_times = np.array(peaks)
916915
else:
917-
raise ValueError("Values for 'peaks' must be an integer or a list/tuple of (tmin, tmax) windows.")
918-
916+
raise ValueError(
917+
"Values for 'peaks' must be an integer or a list/tuple of (tmin, tmax) windows."
918+
)
919+
919920
if isinstance(use_times, str):
920921
if use_times == "interactive":
921922
use_times, n_peaks = "peaks", 1

0 commit comments

Comments
 (0)