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] Fix failing tests in prerelease job due to deprecation and bug in matplotlib 3.8.0rc1 #3902

Merged
merged 4 commits into from Aug 17, 2023

Conversation

ymzayek
Copy link
Member

@ymzayek ymzayek commented Aug 10, 2023

  • Closes #

Changes proposed in this pull request:

@ymzayek
Copy link
Member Author

ymzayek commented Aug 10, 2023

I am still unsure about how to fix the second failing test: nilearn/plotting/tests/test_displays.py::test_contour_fillings_levels_in_add_contours

@github-actions
Copy link
Contributor

github-actions bot commented Aug 10, 2023

👋 @ymzayek Thanks for creating a PR!

Until this PR is ready for review, you can include the [WIP] tag in its title, or leave it as a github draft.

Please make sure it is compliant with our contributing guidelines. In particular, be sure it checks the boxes listed below.

  • PR has an interpretable title.
  • PR links to Github issue with mention Closes #XXXX (see our documentation on PR structure)
  • Code is PEP8-compliant (see our documentation on coding style)
  • Changelog or what's new entry in doc/changes/latest.rst (see our documentation on PR structure)

For new features:

  • There is at least one unit test per new function / class (see our documentation on testing)
  • The new feature is demoed in at least one relevant example.

For bug fixes:

  • There is at least one test that would fail under the original bug conditions.

We will review it as quick as possible, feel free to ping us with questions if needed.

@codecov
Copy link

codecov bot commented Aug 10, 2023

Codecov Report

Merging #3902 (ecbfb2b) into main (48aecfa) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #3902   +/-   ##
=======================================
  Coverage   91.74%   91.74%           
=======================================
  Files         134      134           
  Lines       15733    15735    +2     
  Branches     3273     3274    +1     
=======================================
+ Hits        14434    14436    +2     
  Misses        757      757           
  Partials      542      542           
Flag Coverage Δ
macos-latest_3.10 91.65% <50.00%> (-0.02%) ⬇️
macos-latest_3.11 91.65% <50.00%> (-0.02%) ⬇️
macos-latest_3.8 91.62% <50.00%> (-0.02%) ⬇️
macos-latest_3.9 91.62% <50.00%> (-0.02%) ⬇️
ubuntu-latest_3.10 91.65% <50.00%> (-0.02%) ⬇️
ubuntu-latest_3.11 91.65% <50.00%> (-0.02%) ⬇️
ubuntu-latest_3.8 91.62% <50.00%> (-0.02%) ⬇️
ubuntu-latest_3.9 91.62% <50.00%> (-0.02%) ⬇️
windows-latest_3.10 91.59% <50.00%> (-0.02%) ⬇️
windows-latest_3.11 91.59% <50.00%> (?)
windows-latest_3.8 91.56% <50.00%> (-0.02%) ⬇️
windows-latest_3.9 91.56% <50.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
nilearn/plotting/img_plotting.py 89.28% <100.00%> (+0.04%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ymzayek
Copy link
Member Author

ymzayek commented Aug 11, 2023

The second error (ValueError: minvalue must be less than or equal to maxvalue failure in test_displays.py) can be reproduced with the following code:

import numpy as np
import matplotlib.pyplot as plt

data = np.arange(0.0, 1, 0.01).reshape(4, 25)
threshold = 1e-06
data = np.ma.masked_inside(data, -threshold, threshold, copy=False)

vmin = data.min()
vmax = data.max()
levels = [0.001]  # will pass with [0.01]
_, ax = plt.subplots()
ax.contour(data.copy(), vmin=vmin, vmax=vmax, levels=levels)

Here levels is given a value lower than vmin (0.01). If the value of vmin levels is at 0.01 or above the test will pass

@ymzayek
Copy link
Member Author

ymzayek commented Aug 11, 2023

Seems to me a bug on matplotlib's side. IIUC vmin and vmax should map data values to colors on the colormap and data values lower or higher than vmin/vmax should be mapped to the lowest/highest color in the colomap. For some reason, vmax is equal to zero when levels argument is less than vmin and vmin is given, hence the error that we get. vmax and vmin should not be affected by the levels parameter. Will open an issue there and confirm, then do a hot fix here.

@ymzayek ymzayek changed the title [MAINT] Fix failing tests in prerelease job due to deprecations in matplotlib prerelease [MAINT] Fix failing tests in prerelease job due to deprecation and bug in matplotlib 3.8.0rc1 Aug 17, 2023
@ymzayek ymzayek requested a review from Remi-Gau August 17, 2023 08:19
@ymzayek
Copy link
Member Author

ymzayek commented Aug 17, 2023

The documentation failure doesn't seem to be related. I also failed on the scheduled build on main. Will look into separately. I think this one can be merged

@Remi-Gau
Copy link
Collaborator

thanks for the fix and pinging folks on matplotlib

@Remi-Gau Remi-Gau merged commit 7ed210a into nilearn:main Aug 17, 2023
27 of 28 checks passed
@ymzayek ymzayek deleted the matplotlib_depr branch August 18, 2023 08:40
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.

None yet

2 participants