Skip to content
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

MAINT: Future compatibility with MNE 1.6 #120

Merged
merged 18 commits into from
Sep 14, 2023

Conversation

mscheltienne
Copy link
Collaborator

The FIFF I/O was moved to a different module in mne-tools/mne-python#11903

@codecov
Copy link

codecov bot commented Aug 23, 2023

Codecov Report

Merging #120 (2309859) into main (2562921) will decrease coverage by 0.95%.
Report is 3 commits behind head on main.
The diff coverage is 72.26%.

@@            Coverage Diff             @@
##             main     #120      +/-   ##
==========================================
- Coverage   90.93%   89.99%   -0.95%     
==========================================
  Files          30       30              
  Lines        2615     2648      +33     
  Branches      501      509       +8     
==========================================
+ Hits         2378     2383       +5     
- Misses        136      155      +19     
- Partials      101      110       +9     
Files Changed Coverage Δ
pycrostates/cluster/utils/utils.py 85.71% <ø> (ø)
pycrostates/datasets/lemon/lemon.py 92.85% <ø> (ø)
pycrostates/metrics/davies_bouldin.py 95.00% <ø> (ø)
pycrostates/metrics/silhouette.py 100.00% <ø> (ø)
pycrostates/segmentation/segmentation.py 95.00% <ø> (ø)
pycrostates/utils/_docs.py 92.00% <0.00%> (ø)
pycrostates/viz/segmentation.py 77.96% <ø> (ø)
pycrostates/utils/mixin.py 84.09% <50.00%> (-5.91%) ⬇️
pycrostates/io/fiff.py 75.57% <59.25%> (-2.24%) ⬇️
pycrostates/preprocessing/resample.py 95.89% <60.00%> (-2.69%) ⬇️
... and 17 more

Mathieu Scheltienne added 2 commits August 23, 2023 11:58
@mscheltienne
Copy link
Collaborator Author

Green locally on MNE 1.5 and 1.6, I think I got them all ;)

@mscheltienne mscheltienne requested a review from vferat August 23, 2023 10:03
@mscheltienne
Copy link
Collaborator Author

The most used private import is _picks_to_idx by far, and it should be made public at some point.
For x-ref: mne-tools/mne-python#11913

@vferat
Copy link
Owner

vferat commented Sep 12, 2023

Well done! Everything seems to be working, but it's quickly going to be a headache...
I think we should set mne>=1.6 in the dependencies of our future releases as soon as possible.

We'll keep this PR open until the MNE 1.6 release , I guess?

@mscheltienne
Copy link
Collaborator Author

I think with this PR we can keep the compatibility with MNE above and below 1.6; it's not that much of an headache since the same functions are available in both versions, just in 2 different places.
I'm keeping it open for now, at least until I fix the deprecation warning of numpy 1.25 and add a pre-release workflow testing with numpy 2.0.
Then we can merge, and we must cut a new release before MNE 1.6 is out.

@mscheltienne
Copy link
Collaborator Author

1c6799d is a miss with numpy 1.25 installed. I'll try again later.

@mscheltienne
Copy link
Collaborator Author

Ok, now we have the correct numpy/scipy/mne versions on that pytest run.
That came up right away:

##[warning]in1d is deprecated. Use np.isin instead.

And should be fixed by mne-tools/mne-python#11994 if it's not part of our code.

azure-pipelines.yml Outdated Show resolved Hide resolved
Copy link
Collaborator Author

@mscheltienne mscheltienne left a comment

Choose a reason for hiding this comment

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

@vferat I added the main changes as review comments. The rest is only some clean-up, sorting, .. nothing important.
Hopefully CIs should be green now, with one bemol I did not solve. Warnings do not fail the CI, and I would have missed that numpy 1.25 deprecation warning if I did not click on the CI details.
If I'm right, warnings do fail my github action workflows with a similar configuration, so I'm not sure why it's not the case with azp here.

Good to merge on my end.

Comment on lines +127 to +128
python -m pip install --progress-bar off --force-reinstall git+https://github.com/mne-tools/mne-python
python -m pip install --progress-bar off --upgrade --pre --only-binary :all: -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --timeout=180 numpy scipy scikit-learn matplotlib
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's the one test I changed. Instead of installing only MNE (main), I also install the pre-release version of numpy, scipy, scikit-learn and matplotlib (they need each other to work here, we can't mix a pre-release numpy with the current stable matplotlib or scikit-learn).

Comment on lines +10 to +13
if check_version("mne", "1.6"):
from mne._fiff.pick import _picks_to_idx
else:
from mne.io.pick import _picks_to_idx
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You already saw that, but that's the syntax I used to load correctly the functions we used. I don't think it's adding a large maintenance burden, and we can keep MNE < 1.6 and >= 1.6.
When we will need to remove it, a simple grep on from mne._fiff or on check_version("mne", "1.6") will find all occurences.

Comment on lines -524 to +553
nchan = int(tag.data)
nchan = int(tag.data.item())
elif kind == FIFF.FIFF_CH_INFO:
tag = read_tag(fid, pos)
chs.append(tag.data)
elif kind == FIFF.FIFF_MNE_CUSTOM_REF:
tag = read_tag(fid, pos)
custom_ref_applied = int(tag.data)
custom_ref_applied = int(tag.data.item())
Copy link
Collaborator Author

@mscheltienne mscheltienne Sep 13, 2023

Choose a reason for hiding this comment

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

tag.data is a one element numpy array, and the cast was raising the deprecation warning from numpy.
Fix taken from MNE directly: mne-tools/mne-python#11644

'joblib',
'matplotlib',
'scikit-learn',
'mne>=1.2',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Bumping MNE minimum requirement to 1.2, since this will be released with MNE 1.6, and keeping compatibility with the 4 last versions of our core dependencies is good practice.

@mscheltienne mscheltienne merged commit a8416cc into vferat:main Sep 14, 2023
@mscheltienne mscheltienne deleted the maint-mne-1.6 branch September 14, 2023 09:51
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.

2 participants