Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions doc/changes/dev/13674.other.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve documentation of return values to clarify that methods typically return the original instance type for chaining purposes, by `Aniket Singh Yadav`_.
5 changes: 5 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,18 @@
numpydoc_xref_ignore = {
# words
"and",
"as",
"between",
"data",
"instance",
"instances",
"input",
"of",
"default",
"same",
"shape",
"or",
"the",
"with",
"length",
"pair",
Expand Down
12 changes: 6 additions & 6 deletions mne/_fiff/meas_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def set_montage(

Returns
-------
inst : instance of Raw | Epochs | Evoked
inst : same type as the input data
The instance, modified in-place.

See Also
Expand Down Expand Up @@ -539,7 +539,7 @@ def set_channel_types(self, mapping, *, on_unit_change="warn", verbose=None):

Returns
-------
inst : instance of Raw | Epochs | Evoked
inst : same type as the input data
The instance (modified in place).

.. versionchanged:: 0.20
Expand Down Expand Up @@ -642,7 +642,7 @@ def rename_channels(

Returns
-------
inst : instance of Raw | Epochs | Evoked
inst : same type as the input data
The instance (modified in place).

.. versionchanged:: 0.20
Expand Down Expand Up @@ -787,7 +787,7 @@ def anonymize(self, daysback=None, keep_his=False, verbose=None):

Returns
-------
inst : instance of Raw | Epochs | Evoked
inst : same type as the input data
The modified instance.

Notes
Expand Down Expand Up @@ -816,8 +816,8 @@ def set_meas_date(self, meas_date):

Returns
-------
inst : instance of Raw | Epochs | Evoked
The modified raw instance. Operates in place.
inst : same type as the input data
The modified instance. Operates in place.

See Also
--------
Expand Down
6 changes: 3 additions & 3 deletions mne/_fiff/proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def add_proj(self, projs, remove_existing=False, verbose=None):

Returns
-------
self : instance of Raw | Epochs | Evoked
self : same type as the input data
The data container.
"""
if isinstance(projs, Projection):
Expand Down Expand Up @@ -283,7 +283,7 @@ def apply_proj(self, verbose=None):

Returns
-------
self : instance of Raw | Epochs | Evoked
self : same type as the input data
The instance.

Notes
Expand Down Expand Up @@ -362,7 +362,7 @@ def del_proj(self, idx="all"):

Returns
-------
self : instance of Raw | Epochs | Evoked
self : same type as the input data
The instance.
"""
if isinstance(idx, str) and idx == "all":
Expand Down
6 changes: 3 additions & 3 deletions mne/_fiff/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def add_reference_channels(inst, ref_channels, copy=True):

Returns
-------
inst : instance of Raw | Epochs | Evoked
inst : same type as the input data
Data with added EEG reference channels.

Notes
Expand Down Expand Up @@ -396,7 +396,7 @@ def set_eeg_reference(

Returns
-------
inst : instance of Raw | Epochs | Evoked
inst : same type as the input data
Data with EEG channels re-referenced. If ``ref_channels="average"`` and
``projection=True`` a projection will be added instead of directly
re-referencing the data.
Expand Down Expand Up @@ -575,7 +575,7 @@ def set_bipolar_reference(

Returns
-------
inst : instance of Raw | Epochs | Evoked
inst : same type as the input data
Data with the specified channels re-referenced.

See Also
Expand Down
22 changes: 11 additions & 11 deletions mne/channels/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def set_eeg_reference(

Returns
-------
inst : instance of Raw | Epochs | Evoked
inst : same type as the input data
Data with EEG channels re-referenced. If ``ref_channels='average'``
and ``projection=True`` a projection will be added instead of
directly re-referencing the data.
Expand Down Expand Up @@ -388,7 +388,7 @@ def pick_types(

Returns
-------
inst : instance of Raw, Epochs, or Evoked
inst : same type as the input data
The modified instance.

See Also
Expand Down Expand Up @@ -463,7 +463,7 @@ def pick_channels(self, ch_names, ordered=True, *, verbose=None):

Returns
-------
inst : instance of Raw, Epochs, or Evoked
inst : same type as the input data
The modified instance.

See Also
Expand Down Expand Up @@ -501,7 +501,7 @@ def pick(self, picks, exclude=(), *, verbose=None):

Returns
-------
inst : instance of Raw, Epochs, or Evoked
inst : same type as the input data
The modified instance.
"""
picks = _picks_to_idx(self.info, picks, "all", exclude, allow_empty=False)
Expand Down Expand Up @@ -532,7 +532,7 @@ def reorder_channels(self, ch_names):

Returns
-------
inst : instance of Raw, Epochs, or Evoked
inst : same type as the input data
The modified instance.

See Also
Expand Down Expand Up @@ -569,7 +569,7 @@ def drop_channels(self, ch_names, on_missing="raise"):

Returns
-------
inst : instance of Raw, Epochs, or Evoked
inst : same type as the input data
The modified instance.

See Also
Expand Down Expand Up @@ -691,7 +691,7 @@ def add_channels(self, add_list, force_update_info=False):

Returns
-------
inst : instance of Raw, Epochs, or Evoked
inst : same type as the input data
The modified instance.

See Also
Expand Down Expand Up @@ -812,7 +812,7 @@ def add_reference_channels(self, ref_channels):

Returns
-------
inst : instance of Raw | Epochs | Evoked
inst : same type as the input data
The modified instance.
"""
return add_reference_channels(self, ref_channels, copy=False)
Expand Down Expand Up @@ -878,7 +878,7 @@ def interpolate_bads(

Returns
-------
inst : instance of Raw, Epochs, or Evoked
inst : same type as the input data
The modified instance.

Notes
Expand Down Expand Up @@ -1006,7 +1006,7 @@ def interpolate_to(

Returns
-------
inst : instance of Raw, Epochs, or Evoked
inst : same type as the input data
A new instance with interpolated data and updated channel
information.

Expand Down Expand Up @@ -2015,7 +2015,7 @@ def combine_channels(

Returns
-------
combined_inst : instance of Raw, Epochs, or Evoked
combined_inst : same type as the input data
An MNE-Python object of the same type as the input ``inst``, containing
one virtual channel for each group in ``groups`` (and, if ``keep_stim``
is ``True``, also containing stimulus channels).
Expand Down
6 changes: 3 additions & 3 deletions mne/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2387,7 +2387,7 @@ def savgol_filter(self, h_freq, verbose=None):

Returns
-------
inst : instance of Epochs, Evoked or SourceEstimate
inst : same type as the input data
The object with the filtering applied.

See Also
Expand Down Expand Up @@ -2480,7 +2480,7 @@ def filter(

Returns
-------
inst : instance of Epochs, Evoked, SourceEstimate, or Raw
inst : same type as the input data
The filtered data.

See Also
Expand Down Expand Up @@ -2616,7 +2616,7 @@ def resample(

Returns
-------
inst : instance of Epochs or Evoked
inst : same type as the input data
The resampled object.

See Also
Expand Down
4 changes: 2 additions & 2 deletions mne/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2185,11 +2185,11 @@ def close(self):
pass # noqa

def copy(self):
"""Return copy of Raw instance.
"""Return copy of the instance.

Returns
-------
inst : instance of Raw
inst : same type as the input data
A copy of the instance.
"""
return deepcopy(self)
Expand Down
2 changes: 1 addition & 1 deletion mne/preprocessing/_csd.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def compute_current_source_density(

Returns
-------
inst_csd : instance of Raw, Epochs or Evoked
inst_csd : same type as the input data
The transformed data. Output type will match input type.

Notes
Expand Down
2 changes: 1 addition & 1 deletion mne/preprocessing/_regress.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def regress_artifact(

Returns
-------
inst : instance of Epochs | Raw
inst : same type as the input data
The processed data.
betas : ndarray, shape (n_picks, n_picks_ref)
The betas used during regression.
Expand Down
4 changes: 2 additions & 2 deletions mne/preprocessing/eyetracking/eyetracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def set_channel_types_eyetrack(inst, mapping):

Returns
-------
inst : instance of Raw | Epochs | Evoked
inst : same type as the input data
The instance, modified in place.

Notes
Expand Down Expand Up @@ -179,7 +179,7 @@ def convert_units(inst, calibration, to="radians"):

Returns
-------
inst : instance of Raw | Epochs | Evoked
inst : same type as the input data
The Raw, Epochs, or Evoked instance, modified in place.

Notes
Expand Down
4 changes: 2 additions & 2 deletions mne/preprocessing/ica.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ def get_sources(self, inst, add_channels=None, start=None, stop=None):

Returns
-------
sources : instance of Raw, Epochs or Evoked
sources : same type as the input data
The ICA sources time series.
"""
if isinstance(inst, BaseRaw):
Expand Down Expand Up @@ -2221,7 +2221,7 @@ def apply(

Returns
-------
out : instance of Raw, Epochs or Evoked
out : same type as the input data
The processed data.

Notes
Expand Down
2 changes: 1 addition & 1 deletion mne/preprocessing/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def interpolate_bridged_electrodes(inst, bridged_idx, bad_limit=4):

Returns
-------
inst : instance of Epochs, Evoked, or Raw
inst : same type as the input data
The modified data object.

See Also
Expand Down
2 changes: 1 addition & 1 deletion mne/preprocessing/stim.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def fix_stim_artifact(

Returns
-------
inst : instance of Raw or Evoked or Epochs
inst : same type as the input data
Instance with modified data.
"""
_check_option("mode", mode, ["linear", "window", "constant"])
Expand Down
2 changes: 1 addition & 1 deletion mne/simulation/evoked.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def add_noise(inst, cov, iir_filter=None, random_state=None, verbose=None):

Returns
-------
inst : instance of Evoked, Epochs, or Raw
inst : same type as the input data
The instance, modified to have additional noise.

Notes
Expand Down
2 changes: 1 addition & 1 deletion mne/utils/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def crop(self, tmin=None, tmax=None, include_tmax=True, verbose=None):

Returns
-------
inst : instance of Raw, Epochs, Evoked, AverageTFR, or SourceEstimate
inst : same type as the input data
The cropped time-series object, modified in-place.

Notes
Expand Down