-
Notifications
You must be signed in to change notification settings - Fork 19
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
ENH: Close all Matplotlib
figures in relevant tests explicitly
#167
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #167 +/- ##
==========================================
+ Coverage 66.04% 66.41% +0.37%
==========================================
Files 25 25
Lines 2677 2677
Branches 421 421
==========================================
+ Hits 1768 1778 +10
+ Misses 793 788 -5
+ Partials 116 111 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Oh, does not fix issues, and the ones in 15f4898 are still there: Not sure how to fix this otherwise. Marking as draft. |
524458c
to
cb97b95
Compare
Matplotlib
figures in relevant tests explicitly
Close all `Matplotlib` figures in relevant tests explicitly: when the `output_file` argument is `None` the `plot_carpet` method does not close figures, and thus a warning is raised if the number of open figures exceeds a given value. Use `all` explicitly to guarantee all figures are closed. This change fixes the warnings that have persisted despite commits 626dd35 and 15f4898 claiming to fix these issues. Fixes: ``` nireports/tests/test_reportlets.py::test_nifti_carpetplot /home/runner/work/nireports/nireports/nireports/reportlets/nuisance.py:326: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). Consider using `matplotlib.pyplot.close()`. figure, allaxes = plt.subplots(figsize=(19.2, 10)) ``` and similar warnings. Raised for example in: https://github.com/nipreps/nireports/actions/runs/13276183449/job/37066107605#step:14:341
cb97b95
to
771f87c
Compare
Perhaps a safer way of doing this is a fixture that ensures figures are closed after every test. That said, this one effectively resolves the issue. I'll merge and leave the safer option for our future selves. Thanks! |
Close all
Matplotlib
figures in relevant tests explicitly: when theoutput_file
argument isNone
theplot_carpet
method does not close figures, and thus a warning is raised if the number of open figures exceeds a given value.Use
all
explicitly to guarantee all figures are closed. This change fixes the warnings that have persisted despite commits 626dd35 and 15f4898 claiming to fix these issues.Fixes:
and similar warnings.
Raised for example in:
https://github.com/nipreps/nireports/actions/runs/13276183449/job/37066107605#step:14:341