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

Merged
merged 1 commit into from
Jan 11, 2025

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

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.48%. Comparing base (eb3832c) to head (626dd35).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #155      +/-   ##
==========================================
+ Coverage   65.25%   65.48%   +0.22%     
==========================================
  Files          25       25              
  Lines        2674     2674              
  Branches      420      420              
==========================================
+ Hits         1745     1751       +6     
+ Misses        814      810       -4     
+ Partials      115      113       -2     
Flag Coverage Δ
unittests 64.87% <ø> (?)

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.

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
@jhlegarreta jhlegarreta force-pushed the CloseFiguresExplicitly branch from c9279d7 to 626dd35 Compare January 11, 2025 17:23
@jhlegarreta jhlegarreta merged commit 7f371de into nipreps:main Jan 11, 2025
16 checks passed
@jhlegarreta jhlegarreta deleted the CloseFiguresExplicitly branch January 11, 2025 21:55
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