-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix copy-view issue in epochs #12121
Merged
Merged
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5bd0dac
Fix copy-view issue in epochs
pablomainar f0f7173
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 15816db
Add PR suggestions
pablomainar 98b01b6
Adapt tests to new interface
pablomainar 19a30da
Merge branch 'main' into fix
drammock 6436a68
Add tests for copy
pablomainar d740c31
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1346645
Use shares_memory in test
pablomainar d310732
Merge branch 'main' into fix
larsoner 69ca518
FIX: Close
larsoner 31c299b
Merge remote-tracking branch 'upstream/main' into fix
larsoner a0c7ade
FIX: More
larsoner 09792b5
FIX: Green [circle full]
larsoner 1135dd9
Merge remote-tracking branch 'upstream/main' into fix
larsoner 01e1d9c
FIX: Examples
larsoner b2e7c46
FIX: Simpler
larsoner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1588,6 +1588,7 @@ def _get_data( | |
units=None, | ||
tmin=None, | ||
tmax=None, | ||
copy=True, | ||
on_empty="warn", | ||
verbose=None, | ||
): | ||
|
@@ -1672,6 +1673,9 @@ def _get_data( | |
if (units is not None) and out: | ||
ch_factors = _get_ch_factors(self, units, picks) | ||
|
||
if copy: | ||
data = data.copy() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest moving this up about 25 lines, inside the |
||
|
||
if self._bad_dropped: | ||
if not out: | ||
return | ||
|
@@ -1796,7 +1800,9 @@ def _detrend_picks(self): | |
return [] | ||
|
||
@fill_doc | ||
def get_data(self, picks=None, item=None, units=None, tmin=None, tmax=None): | ||
def get_data( | ||
self, picks=None, item=None, units=None, tmin=None, tmax=None, copy=True | ||
): | ||
"""Get all epochs as a 3D array. | ||
|
||
Parameters | ||
|
@@ -1821,13 +1827,20 @@ def get_data(self, picks=None, item=None, units=None, tmin=None, tmax=None): | |
End time of data to get in seconds. | ||
|
||
.. versionadded:: 0.24.0 | ||
copy : bool | None | ||
If true (default) then a copy is returned. If false, | ||
a view is returned if the requirements are met. | ||
If picks, item, tmin or tmax are not None, a copy | ||
is returned. | ||
larsoner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Returns | ||
------- | ||
data : array of shape (n_epochs, n_channels, n_times) | ||
A view on epochs data. | ||
""" | ||
return self._get_data(picks=picks, item=item, units=units, tmin=tmin, tmax=tmax) | ||
return self._get_data( | ||
picks=picks, item=item, units=units, tmin=tmin, tmax=tmax, copy=copy | ||
) | ||
|
||
@verbose | ||
def apply_function( | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this private method we should probably default to
copy=False
so that we're not making unnecessary copies in internal calls that use the private API.