From 3a4b51ae5949e3c998fb5a0f6091d58247d32ff9 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 26 May 2025 15:58:41 +0200 Subject: [PATCH 1/3] fix set_matplotlib_formats being removed from Ipython the function has been deprecated from IPython 7.14 and has been removed in IPython 9.0 (cherry picked from commit 05958bc7a67e1b5b7945c5fd5c2dcd1e420781ca) --- src/resources/jupyter/lang/python/setup.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/resources/jupyter/lang/python/setup.py b/src/resources/jupyter/lang/python/setup.py index 2206217f8f7..279cd5b2c00 100644 --- a/src/resources/jupyter/lang/python/setup.py +++ b/src/resources/jupyter/lang/python/setup.py @@ -22,7 +22,14 @@ plt.rcParams['figure.figsize'] = (fig_width, fig_height) plt.rcParams['figure.dpi'] = fig_dpi plt.rcParams['savefig.dpi'] = "figure" - from IPython.display import set_matplotlib_formats + + # IPython 7.14 deprecated set_matplotlib_formats from IPython + try: + from matplotlib_inline.backend_inline import set_matplotlib_formats + except ImportError: + # Fall back to deprecated location for older IPython versions + from IPython.display import set_matplotlib_formats + set_matplotlib_formats(fig_format) except Exception: pass From 828d9a6e6357c512cc7bf80f50181f24a232783e Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 26 May 2025 15:51:24 +0200 Subject: [PATCH 2/3] tests - add a test for fig-format with matplotlib (cherry picked from commit a61d45dc2e7a8b0db55e1599b589e4997eeca9ba) --- .../jupyter/fig-format/matplotlib-svg.qmd | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/docs/smoke-all/jupyter/fig-format/matplotlib-svg.qmd diff --git a/tests/docs/smoke-all/jupyter/fig-format/matplotlib-svg.qmd b/tests/docs/smoke-all/jupyter/fig-format/matplotlib-svg.qmd new file mode 100644 index 00000000000..e79395b6cb7 --- /dev/null +++ b/tests/docs/smoke-all/jupyter/fig-format/matplotlib-svg.qmd @@ -0,0 +1,28 @@ +--- +title: Get SVG from matplotlib +format: + html: + fig-format: svg +_quarto: + tests: + html: + ensureHtmlElements: + - ['figure.figure img[src$=".svg"]'] + - ['figure.figure img[src$=".png"]'] +--- + +```{python} +import matplotlib.pyplot as plt +import numpy as np + +fig, ax = plt.subplots() + +x = np.linspace(0, 4 * np.pi, 100) +y1 = np.sin(x) +y2 = np.cos(x) + +ax.set_title("Sine and Cosine") +ax.plot(x, y1) +ax.plot(x, y2) +ax.legend(["Sine", "Cosine"]) +``` From 19248dda283b3069b80da099e6f222a6a9039223 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 22 Jul 2025 15:36:21 +0200 Subject: [PATCH 3/3] Add to changelog --- news/changelog-1.7.md | 1 + 1 file changed, 1 insertion(+) diff --git a/news/changelog-1.7.md b/news/changelog-1.7.md index c7c34606525..96449a11ff5 100644 --- a/news/changelog-1.7.md +++ b/news/changelog-1.7.md @@ -3,6 +3,7 @@ ## In this release - ([#13051](https://github.com/quarto-dev/quarto-cli/issues/13051)): Fixed support for captioned Markdown table inside Div syntax for crossref. This is special handling, but this could be output by function like `knitr::kable()` with old option support. +- ([#12753](https://github.com/quarto-dev/quarto-cli/issues/12753)): Support change in IPython 9+ and import `set_matplotlib_formats` from `matplotlib_inline.backend_inline` in the internal `setup.py` script used to initialize rendering with Jupyter engine. ## In previous releases