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

ENH: Close figures in test explicitly #155

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jhlegarreta
Copy link
Collaborator

Close figures in test 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.

Fixes:

nireports/tests/test_reportlets.py::test_carpetplot[linkage-0.7]
  /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))

reported for example in:
https://github.com/nipreps/nireports/actions/runs/12681153218/job/35344304375#step:12:351

Close figures in test 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.

Fixes:
```
nireports/tests/test_reportlets.py::test_carpetplot[linkage-0.7]
  /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))
```

reported for example in:
https://github.com/nipreps/nireports/actions/runs/12681153218/job/35344304375#step:12:351
Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.16%. Comparing base (d88ca78) to head (c9279d7).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #155      +/-   ##
==========================================
+ Coverage   64.78%   65.16%   +0.37%     
==========================================
  Files          23       25       +2     
  Lines        2644     2899     +255     
  Branches      367      522     +155     
==========================================
+ Hits         1713     1889     +176     
- Misses        816      881      +65     
- Partials      115      129      +14     
Flag Coverage Δ
unittests 64.88% <ø> (?)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

1 participant