Skip to content

Commit e9f9bf6

Browse files
Aniketsywmvanvliet
andauthored
Doc- clarify return types as instance of original type (#13674)
Co-authored-by: Marijn van Vliet <w.m.vanvliet@gmail.com>
1 parent ce94c05 commit e9f9bf6

16 files changed

Lines changed: 44 additions & 38 deletions

File tree

doc/changes/dev/13674.other.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve documentation of return values to clarify that methods typically return the original instance type for chaining purposes, by `Aniket Singh Yadav`_.

doc/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,18 @@
318318
numpydoc_xref_ignore = {
319319
# words
320320
"and",
321+
"as",
321322
"between",
323+
"data",
322324
"instance",
323325
"instances",
326+
"input",
324327
"of",
325328
"default",
329+
"same",
326330
"shape",
327331
"or",
332+
"the",
328333
"with",
329334
"length",
330335
"pair",

mne/_fiff/meas_info.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def set_montage(
397397
398398
Returns
399399
-------
400-
inst : instance of Raw | Epochs | Evoked
400+
inst : same type as the input data
401401
The instance, modified in-place.
402402
403403
See Also
@@ -539,7 +539,7 @@ def set_channel_types(self, mapping, *, on_unit_change="warn", verbose=None):
539539
540540
Returns
541541
-------
542-
inst : instance of Raw | Epochs | Evoked
542+
inst : same type as the input data
543543
The instance (modified in place).
544544
545545
.. versionchanged:: 0.20
@@ -642,7 +642,7 @@ def rename_channels(
642642
643643
Returns
644644
-------
645-
inst : instance of Raw | Epochs | Evoked
645+
inst : same type as the input data
646646
The instance (modified in place).
647647
648648
.. versionchanged:: 0.20
@@ -787,7 +787,7 @@ def anonymize(self, daysback=None, keep_his=False, verbose=None):
787787
788788
Returns
789789
-------
790-
inst : instance of Raw | Epochs | Evoked
790+
inst : same type as the input data
791791
The modified instance.
792792
793793
Notes
@@ -816,8 +816,8 @@ def set_meas_date(self, meas_date):
816816
817817
Returns
818818
-------
819-
inst : instance of Raw | Epochs | Evoked
820-
The modified raw instance. Operates in place.
819+
inst : same type as the input data
820+
The modified instance. Operates in place.
821821
822822
See Also
823823
--------

mne/_fiff/proj.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def add_proj(self, projs, remove_existing=False, verbose=None):
243243
244244
Returns
245245
-------
246-
self : instance of Raw | Epochs | Evoked
246+
self : same type as the input data
247247
The data container.
248248
"""
249249
if isinstance(projs, Projection):
@@ -283,7 +283,7 @@ def apply_proj(self, verbose=None):
283283
284284
Returns
285285
-------
286-
self : instance of Raw | Epochs | Evoked
286+
self : same type as the input data
287287
The instance.
288288
289289
Notes
@@ -362,7 +362,7 @@ def del_proj(self, idx="all"):
362362
363363
Returns
364364
-------
365-
self : instance of Raw | Epochs | Evoked
365+
self : same type as the input data
366366
The instance.
367367
"""
368368
if isinstance(idx, str) and idx == "all":

mne/_fiff/reference.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def add_reference_channels(inst, ref_channels, copy=True):
228228
229229
Returns
230230
-------
231-
inst : instance of Raw | Epochs | Evoked
231+
inst : same type as the input data
232232
Data with added EEG reference channels.
233233
234234
Notes
@@ -396,7 +396,7 @@ def set_eeg_reference(
396396
397397
Returns
398398
-------
399-
inst : instance of Raw | Epochs | Evoked
399+
inst : same type as the input data
400400
Data with EEG channels re-referenced. If ``ref_channels="average"`` and
401401
``projection=True`` a projection will be added instead of directly
402402
re-referencing the data.
@@ -575,7 +575,7 @@ def set_bipolar_reference(
575575
576576
Returns
577577
-------
578-
inst : instance of Raw | Epochs | Evoked
578+
inst : same type as the input data
579579
Data with the specified channels re-referenced.
580580
581581
See Also

mne/channels/channels.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def set_eeg_reference(
325325
326326
Returns
327327
-------
328-
inst : instance of Raw | Epochs | Evoked
328+
inst : same type as the input data
329329
Data with EEG channels re-referenced. If ``ref_channels='average'``
330330
and ``projection=True`` a projection will be added instead of
331331
directly re-referencing the data.
@@ -388,7 +388,7 @@ def pick_types(
388388
389389
Returns
390390
-------
391-
inst : instance of Raw, Epochs, or Evoked
391+
inst : same type as the input data
392392
The modified instance.
393393
394394
See Also
@@ -463,7 +463,7 @@ def pick_channels(self, ch_names, ordered=True, *, verbose=None):
463463
464464
Returns
465465
-------
466-
inst : instance of Raw, Epochs, or Evoked
466+
inst : same type as the input data
467467
The modified instance.
468468
469469
See Also
@@ -501,7 +501,7 @@ def pick(self, picks, exclude=(), *, verbose=None):
501501
502502
Returns
503503
-------
504-
inst : instance of Raw, Epochs, or Evoked
504+
inst : same type as the input data
505505
The modified instance.
506506
"""
507507
picks = _picks_to_idx(self.info, picks, "all", exclude, allow_empty=False)
@@ -532,7 +532,7 @@ def reorder_channels(self, ch_names):
532532
533533
Returns
534534
-------
535-
inst : instance of Raw, Epochs, or Evoked
535+
inst : same type as the input data
536536
The modified instance.
537537
538538
See Also
@@ -569,7 +569,7 @@ def drop_channels(self, ch_names, on_missing="raise"):
569569
570570
Returns
571571
-------
572-
inst : instance of Raw, Epochs, or Evoked
572+
inst : same type as the input data
573573
The modified instance.
574574
575575
See Also
@@ -691,7 +691,7 @@ def add_channels(self, add_list, force_update_info=False):
691691
692692
Returns
693693
-------
694-
inst : instance of Raw, Epochs, or Evoked
694+
inst : same type as the input data
695695
The modified instance.
696696
697697
See Also
@@ -812,7 +812,7 @@ def add_reference_channels(self, ref_channels):
812812
813813
Returns
814814
-------
815-
inst : instance of Raw | Epochs | Evoked
815+
inst : same type as the input data
816816
The modified instance.
817817
"""
818818
return add_reference_channels(self, ref_channels, copy=False)
@@ -878,7 +878,7 @@ def interpolate_bads(
878878
879879
Returns
880880
-------
881-
inst : instance of Raw, Epochs, or Evoked
881+
inst : same type as the input data
882882
The modified instance.
883883
884884
Notes
@@ -1006,7 +1006,7 @@ def interpolate_to(
10061006
10071007
Returns
10081008
-------
1009-
inst : instance of Raw, Epochs, or Evoked
1009+
inst : same type as the input data
10101010
A new instance with interpolated data and updated channel
10111011
information.
10121012
@@ -2015,7 +2015,7 @@ def combine_channels(
20152015
20162016
Returns
20172017
-------
2018-
combined_inst : instance of Raw, Epochs, or Evoked
2018+
combined_inst : same type as the input data
20192019
An MNE-Python object of the same type as the input ``inst``, containing
20202020
one virtual channel for each group in ``groups`` (and, if ``keep_stim``
20212021
is ``True``, also containing stimulus channels).

mne/filter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,7 +2387,7 @@ def savgol_filter(self, h_freq, verbose=None):
23872387
23882388
Returns
23892389
-------
2390-
inst : instance of Epochs, Evoked or SourceEstimate
2390+
inst : same type as the input data
23912391
The object with the filtering applied.
23922392
23932393
See Also
@@ -2480,7 +2480,7 @@ def filter(
24802480
24812481
Returns
24822482
-------
2483-
inst : instance of Epochs, Evoked, SourceEstimate, or Raw
2483+
inst : same type as the input data
24842484
The filtered data.
24852485
24862486
See Also
@@ -2616,7 +2616,7 @@ def resample(
26162616
26172617
Returns
26182618
-------
2619-
inst : instance of Epochs or Evoked
2619+
inst : same type as the input data
26202620
The resampled object.
26212621
26222622
See Also

mne/io/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,11 +2185,11 @@ def close(self):
21852185
pass # noqa
21862186

21872187
def copy(self):
2188-
"""Return copy of Raw instance.
2188+
"""Return copy of the instance.
21892189
21902190
Returns
21912191
-------
2192-
inst : instance of Raw
2192+
inst : same type as the input data
21932193
A copy of the instance.
21942194
"""
21952195
return deepcopy(self)

mne/preprocessing/_csd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def compute_current_source_density(
9090
9191
Returns
9292
-------
93-
inst_csd : instance of Raw, Epochs or Evoked
93+
inst_csd : same type as the input data
9494
The transformed data. Output type will match input type.
9595
9696
Notes

mne/preprocessing/_regress.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def regress_artifact(
6363
6464
Returns
6565
-------
66-
inst : instance of Epochs | Raw
66+
inst : same type as the input data
6767
The processed data.
6868
betas : ndarray, shape (n_picks, n_picks_ref)
6969
The betas used during regression.

0 commit comments

Comments
 (0)