matplotlib / matplotlib/ipympl

ipympl changes MPL backend on import

Open
#623 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
1.7k
Forks
234
PR merge metrics
No merged PRs in 30d

Description

In mne-python (see above), we have a functionality called sys_info, which gives us (among other things) the versions of all sorts of installed packages.

For this reason, we also import ipympl.

At import time, ipympl actually changes the MPL backend.

Is this something that could be avoided? This change in backend was very surprising to us and it took an in-depth profiling to identify it as the cause of a massive memory leak in a pipeline that produced several plots on each iteration, never closing them due to the backend change.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the import-time behavior described in the issue and the linked mne-python pull request review, focusing on where importing ipympl changes the Matplotlib backend. Reproduce this with the sys_info-style import sequence and verify that importing ipympl no longer changes the backend or causes the reported plot-lifecycle problem.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, matplotlib, python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.