Skip to content

MRG: Add copy param to iter_evoked - #7164

Merged
agramfort merged 5 commits into
mne-tools:masterfrom
agramfort:iter_evoked_copy
Jan 6, 2020
Merged

agramfort merged 5 commits into
mne-tools:masterfrom
agramfort:iter_evoked_copy

Conversation

@agramfort

Copy link
Copy Markdown
Member

@agramfort agramfort mentioned this pull request Dec 28, 2019
@codecov

codecov Bot commented Dec 28, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #7164 into master will decrease coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #7164      +/-   ##
==========================================
- Coverage   89.76%   89.75%   -0.01%     
==========================================
  Files         444      444              
  Lines       79352    79353       +1     
  Branches    12683    12683              
==========================================
- Hits        71228    71227       -1     
- Misses       5342     5344       +2     
  Partials     2782     2782

@jona-sassenhagen jona-sassenhagen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jona-sassenhagen

Copy link
Copy Markdown
Contributor

I think this could be set to copy=False for a speed boost:

plot_compare_evokeds({'cond': list(epochs.iter_evoked())},

@jona-sassenhagen

Copy link
Copy Markdown
Contributor

I am sure you've thought about this, but the iteration over the data array returns views, correct - and if the evoked objects' data are modified in-place, the original data does not change, right?

@larsoner

Copy link
Copy Markdown
Member

the iteration over the data array returns views, correct - and if the evoked objects' data are modified in-place, the original data does not change, right?

It will change. So if copy then we should probably also copy the data.

@larsoner larsoner changed the title add copy param to iter_evoked. fix #6250 MRG: Add copy param to iter_evoked Dec 28, 2019
Comment thread mne/epochs.py
info = self.info
if copy:
info = deepcopy(self.info)
data = data.copy()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@larsoner are you sure there was not a copy already before? This now may change old behavior so could be an API change

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably then it’d be a bugfix

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data was not copied before, it was a view. So on master data is not copied, but info is copied. This is inconsistent and should be fixed. The current version of this PR fixes it so either info and data are copied, or neither are.

My vote would be to have copy=False as the default, since that was closest to what was being done before in terms of the data, which is probably what most users think about. But I doubt the number of people doing in-place modifications with an iter_evoked is quite small.

@agramfort

agramfort commented Jan 4, 2020 via email

Copy link
Copy Markdown
Member Author

@agramfort

agramfort commented Jan 5, 2020 via email

Copy link
Copy Markdown
Member Author

@larsoner

larsoner commented Jan 5, 2020

Copy link
Copy Markdown
Member

Yeah I think so

@agramfort
agramfort merged commit c4d352a into mne-tools:master Jan 6, 2020
@agramfort

Copy link
Copy Markdown
Member Author

thx @larsoner @jona-sassenhagen for the reviews !

AdoNunes pushed a commit to AdoNunes/mne-python that referenced this pull request Apr 6, 2020
* add copy param to iter_evoked. fix mne-tools#6250

* fix

* FIX: Flake and data copy

* update latest.inc

* change default

Co-authored-by: Eric Larson <[email protected]>
AdoNunes pushed a commit to AdoNunes/mne-python that referenced this pull request Apr 6, 2020
* add copy param to iter_evoked. fix mne-tools#6250

* fix

* FIX: Flake and data copy

* update latest.inc

* change default

Co-authored-by: Eric Larson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

speed up iter_evoked?

3 participants