Skip to content

Commit

Permalink
Backport PR #3499: Fix compatibility with IPython 9 (#3500)
Browse files Browse the repository at this point in the history
Co-authored-by: Philipp A <[email protected]>
  • Loading branch information
meeseeksmachine and flying-sheep authored Mar 11, 2025
1 parent d1e8fed commit b9ec970
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/release-notes/3499.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix compatibility with IPython 9 {smaller}`P Angerer`
12 changes: 8 additions & 4 deletions src/scanpy/_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def set_figure_params(
format: _Format = "pdf",
facecolor: str | None = None,
transparent: bool = False,
ipython_format: str = "png2x",
ipython_format: str | Iterable[str] = "retina",
) -> None:
"""Set resolution/size, styling and format of figures.
Expand Down Expand Up @@ -456,15 +456,19 @@ def set_figure_params(
`rcParams['savefig.transparent']`.
ipython_format
Only concerns the notebook/IPython environment; see
:func:`~IPython.display.set_matplotlib_formats` for details.
`matplotlib_inline.backend_inline.set_matplotlib_formats
<https://github.com/ipython/matplotlib-inline/blob/b93777db35267acefe6e37d14214360362d2e8b2/matplotlib_inline/backend_inline.py#L280-L281>`_
for details.
"""
if self._is_run_from_ipython():
import IPython
# No docs yet: https://github.com/ipython/matplotlib-inline/issues/12
from matplotlib_inline.backend_inline import set_matplotlib_formats

if isinstance(ipython_format, str):
ipython_format = [ipython_format]
IPython.display.set_matplotlib_formats(*ipython_format)

set_matplotlib_formats(*ipython_format)

from matplotlib import rcParams

Expand Down

0 comments on commit b9ec970

Please sign in to comment.