Skip to content

Commit e6f3f51

Browse files
committed
Say in the signatures that epochs data may arrive per epoch
BaseEpochs and EpochsArray both accept a list holding one array per epoch, and tmin may be given per event, but the annotations still described only the rectangular case, so passing what the docstrings document was reported as a type error. The fixed-duration branch of BaseEpochs.__init__ asserts the list is not present before reshaping, which is the branch it already relies on.
1 parent fb3d4f1 commit e6f3f51

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

mne/epochs.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,9 +579,11 @@ class BaseEpochs(
579579
Parameters
580580
----------
581581
%(info_not_none)s
582-
data : ndarray | None
582+
data : ndarray | list of ndarray | None
583583
If ``None``, data will be read from the Raw object. If ndarray, must be
584-
of shape (n_epochs, n_channels, n_times).
584+
of shape (n_epochs, n_channels, n_times). A list of
585+
(n_channels, n_times) arrays, one per epoch, gives epochs of differing
586+
duration.
585587
%(events_epochs)s
586588
%(event_id)s
587589
%(epochs_tmin_tmax)s
@@ -639,7 +641,7 @@ class BaseEpochs(
639641
def __init__(
640642
self,
641643
info: Info,
642-
data: np.ndarray | None,
644+
data: np.ndarray | list[np.ndarray] | None,
643645
events: np.ndarray,
644646
event_id: int | list[int] | dict | str | list[str] | None = None,
645647
tmin: float | np.ndarray = -0.2,
@@ -807,6 +809,7 @@ def __init__(
807809
self._do_baseline = False
808810
else:
809811
assert decim == 1
812+
assert not isinstance(data, list) # only the branch above takes a list
810813
if (
811814
data.ndim != 3
812815
or data.shape[2] != round((tmax - tmin) * self.info["sfreq"]) + 1

0 commit comments

Comments
 (0)