Skip to content

Commit 2c0734b

Browse files
committed
MAINT: Fix style and documentation formatting
1 parent fa835bf commit 2c0734b

File tree

3 files changed

+35
-27
lines changed

3 files changed

+35
-27
lines changed

mne/viz/evoked.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,10 +1826,13 @@ def plot_evoked_joint(
18261826
between the first and last time instant will be shown. If ``"peaks"``,
18271827
finds time points automatically by checking for 3 local maxima in
18281828
Global Field Power. Defaults to ``"peaks"``.
1829-
If a dict, the key must be ``"peaks"`` with a value of either an integer
1830-
(number of peaks to find) or a list/tuple of tuples (time windows to
1831-
find a peak in). If you want to use evenly spaced time points in an
1832-
interval, use :func:`numpy.linspace`.
1829+
If a dict, the key must be ``"peaks"`` and the value
1830+
can be :
1831+
* an int (number of peaks to find over the whole epoch)
1832+
* a list of tuples (time windows to find one peak in each)
1833+
1834+
Defaults to ``"peaks"``. If you want to use evenly spaced time points in
1835+
an interval, use :func:`numpy.linspace`.
18331836
title : str | None
18341837
The title. If ``None``, suppress printing channel type title. If an
18351838
empty string, a default title is created. Defaults to ''. If custom
@@ -1896,14 +1899,18 @@ def plot_evoked_joint(
18961899
n_topomaps = 3 + 1
18971900
elif isinstance(times, dict) and "peaks" in times:
18981901
if len(times) != 1:
1899-
raise ValueError("If 'times' is a dict, it must have only one key 'peaks'.")
1902+
raise ValueError(
1903+
"If 'times' is a dict, it must have only one key 'peaks'."
1904+
)
19001905
val = times["peaks"]
19011906
if isinstance(val, int):
19021907
n_topomaps = val + 1
19031908
elif isinstance(val, (list, tuple)):
19041909
n_topomaps = len(val) + 1
19051910
else:
1906-
raise ValueError("Values for 'peaks' must be int or list/tuple of tuples.")
1911+
raise ValueError(
1912+
"Values for 'peaks' must be int or list/tuple of tuples."
1913+
)
19071914
else:
19081915
assert not isinstance(times, str)
19091916
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: 8 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,15 @@ 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 "
918+
" (tmin, tmax) windows."
919+
)
920+
919921
if isinstance(use_times, str):
920922
if use_times == "interactive":
921923
use_times, n_peaks = "peaks", 1

0 commit comments

Comments
 (0)