Skip to content

Conversation

@hoechenberger
Copy link
Member

Fixes #9273

We set 100 * eps as the lower bound.

@hoechenberger

This comment has been minimized.

@hoechenberger
Copy link
Member Author

@drammock @larsoner It seems there's a problem with Circle that's unrelated to my PR, could you please have a look?

@drammock
Copy link
Member

drammock commented Apr 18, 2021 via email

@hoechenberger
Copy link
Member Author

So should I pin our jinja to an older version perhaps?

@drammock
Copy link
Member

So should I pin our jinja to an older version perhaps?

we don't directly depend on jinja; it's a sphinx dependency. I think the right thing to do is to open an issue upstream in the sphinx repo, and add this particular deprecation warning to the reset_warnings() function in doc/conf.py so that in the meantime it won't affect our doc builds (I think that's the right place, as opposed to mne/conftest.py... I think conftest is for warnings generated by our tests, and reset_warnings() in conf.py is for warnings generated during doc builds). @larsoner can correct me if I'm wrong.

@larsoner
Copy link
Member

That's correct!

try:
eps = 1e2 * np.finfo(x0.dtype).eps
except ValueError: # int dtypes are exact
eps = 0.
Copy link
Member

Choose a reason for hiding this comment

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

I don't like try except blocks. They are too implicit. Here i would say that either we support integer inputs and you should check that dtype is int-like or if not you should cast to a float with the same nbytes. See

https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/utils/validation.py#L173

how it's done in sklearn.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm now simply casting unless it's already a float, see 20361b4

You okay with that?

@larsoner larsoner added this to the 0.23 milestone Apr 19, 2021
doc/conf.py Outdated
'ignore', message="can't resolve package from", category=ImportWarning)
warnings.filterwarnings(
'ignore', message='.*mne-realtime.*', category=DeprecationWarning)
warnings.filterwarnings(
Copy link
Member

Choose a reason for hiding this comment

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

This was errantly duplicated

Also perhaps you don't need these changes anymore? The latest CircleCI PR doc builds have been green at least

Copy link
Member Author

Choose a reason for hiding this comment

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

I reverted the changes and now we get the deprecation warnings again and an exception :(

Copy link
Member

Choose a reason for hiding this comment

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

looks like you reverted too much! the jinja glue line was supposed to stay... it's just the accidentally dupllicated mne-realtime line that needed reverting

Copy link
Member

Choose a reason for hiding this comment

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

I thought even the jinja-glue wouldn't be needed since builds are passing on other PRs. But maybe this PR changes something that makes it necessary? Or the caching is making different builds use different versions of Sphinx or something?

Copy link
Member

Choose a reason for hiding this comment

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

version of sphinx is the same between this failed circleCI build and the successful one on #9316 (both use 4.0.0b1). Jinja is different (3.0.0rc1 here versus 3.0.0a1 there)

Copy link
Member

Choose a reason for hiding this comment

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

the jinja error is happening on #9292 now also.

Copy link
Member

Choose a reason for hiding this comment

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

Feel free to port the fix over. Personally I would do it just by adding another line to the DeprecationWarnings list a few lines above

Copy link
Member

Choose a reason for hiding this comment

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

(around line 770 of conf.py)

raise ValueError(
f'The selected threshold value is too small for peak detection '
f'due to inevitable floating-point imprecisions.\nPlease pick a '
f'value >= {eps:g} (You passed thresh={thresh})')
Copy link
Member

Choose a reason for hiding this comment

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

I am not convinced this is right. We have to keep in mind eps is relative to 1., it's not an absolute minimum delta between floats (that would be finfo(x0.dtype).tiny, and even that's before going denormalized). For example consider this on main, which seems correct:

>>> import mne
>>> import numpy as np 
>>> x = np.full(1000, 1e-20)
>>> x[500] = 2e-20
>>> mne.preprocessing.peak_finder(x)
(array([500]), array([2.e-20]))

But we have

>>> (np.max(x) - np.min(x)) / 4
2.5e-21
>>> 1e2 * np.finfo(x.dtype).eps
2.220446049250313e-14

So this PR will find nothing significant.

For EEG/EOG data in V, this might be okay. For data in T or T/M, these hang out around 1e-12 so this can become problematic.

@larsoner
Copy link
Member

Moving to 0.24 so that whatever solution we come up with we have time to test properly before release

@larsoner larsoner modified the milestones: 0.23, 0.24 Apr 23, 2021
@larsoner
Copy link
Member

Bumping milestone again

@larsoner larsoner modified the milestones: 0.24, 1.0 Oct 22, 2021
@hoechenberger
Copy link
Member Author

Let's keep track of this in #9273.

Closing.

@hoechenberger hoechenberger deleted the hoechenberger/issue9273 branch December 7, 2021 16:16
@hoechenberger hoechenberger restored the hoechenberger/issue9273 branch December 7, 2021 16:16
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.

find_eog_events() & find_ecg_events() find events when there are literally none

4 participants