-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
WIP FIX Deprecate use_rounding=False default in time_as_index [circle full] – take 2 #13907
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
base: main
Are you sure you want to change the base?
Changes from 7 commits
fa5c6e6
aeb99e9
67e1796
b57e193
f7c6ede
a190f08
025c211
b712a6a
a35d9b4
51f0b56
1bc0937
8372c7c
1f12a5a
96e72bb
b706eac
7d6df4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -493,16 +493,25 @@ def _check_decim(info, decim, offset, check_filter=True): | |
| class TimeMixin: | ||
| """Class for time operations on any MNE object that has a time axis.""" | ||
|
|
||
| def time_as_index(self, times, use_rounding=False): | ||
| def time_as_index(self, times, use_rounding=None): | ||
|
mathias-sm marked this conversation as resolved.
Outdated
|
||
| """Convert time to indices. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| times : list-like | float | int | ||
| List of numbers or a number representing points in time. | ||
| use_rounding : bool | ||
| If True, use rounding (instead of truncation) when converting | ||
| times to indices. This can help avoid non-unique indices. | ||
| use_rounding : bool | None | ||
| If True, use rounding when converting times to indices. This can | ||
| help avoid non-unique indices. | ||
| If False, use truncation when converting times to indices. | ||
| If None (the default), rounding is used but a FutureWarning is | ||
| emitted. Pass ``True`` or ``False`` explicitly to silence the | ||
| warning. | ||
|
|
||
| .. versionchanged:: 2.0 | ||
| The default changed from ``False`` to ``None``, which will | ||
| round and emit a warning. In a future release the default | ||
| will change to ``True``. | ||
|
|
||
| Returns | ||
| ------- | ||
|
|
@@ -511,6 +520,18 @@ def time_as_index(self, times, use_rounding=False): | |
| """ | ||
| from ..source_estimate import _BaseSourceEstimate | ||
|
|
||
| if use_rounding is None: | ||
| # Turned off temporarily to see the impact of the change without | ||
| # crashing on a FutureWarning | ||
|
Member
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. To really see the impact I would suggest following my RuntimeError suggestion from #13634 (comment) By computing both ways and raising this error it would clearly show all tests and examples (with a
Contributor
Author
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. Ah yes indeed somehow I had forgotten about this. Quick exploration of that: it breaks 5 tests. I will push this after making sure that I'm doing things right to get them from the CI. |
||
| # | ||
| # warn( | ||
| # "The default of use_rounding=False is being changed to True " | ||
| # "in a future release. Pass use_rounding=True or " | ||
| # "use_rounding=False explicitly to silence this warning.", | ||
| # FutureWarning, | ||
| # ) | ||
| use_rounding = True | ||
|
|
||
| if isinstance(self, _BaseSourceEstimate): | ||
| sfreq = 1.0 / self.tstep | ||
| else: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.