From 82bcc49d46dbbe429c39dc0e3902fcec7a385963 Mon Sep 17 00:00:00 2001 From: Andrew Sazonov Date: Mon, 11 Aug 2025 16:45:46 +0200 Subject: [PATCH 1/3] Adds debug logging for plot display checks --- src/easydiffraction/plotting/plotters/plotter_plotly.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/easydiffraction/plotting/plotters/plotter_plotly.py b/src/easydiffraction/plotting/plotters/plotter_plotly.py index 4f68c1c3..e645e6a6 100644 --- a/src/easydiffraction/plotting/plotters/plotter_plotly.py +++ b/src/easydiffraction/plotting/plotters/plotter_plotly.py @@ -110,6 +110,10 @@ def plot( # This can lead to warnings in Jupyter notebooks: # WARNING: skipping unknown output mime type: application/vnd.plotly.v1+json [mystnb.unknown_mime_type] if is_notebook() or is_pycharm() or display is None or HTML is None: + print( + f'----DEBUG----: fig.show(): is_notebook()={is_notebook()}, is_pycharm()={is_pycharm()}, ' + f'display={display}, HTML={HTML}' + ) fig.show(config=config) # If IPython is available, we can convert the figure to HTML and @@ -124,4 +128,5 @@ def plot( ) # Display it in the notebook + print('----DEBUG----: display(HTML(html_fig))') display(HTML(html_fig)) From ad406cdb2b5ae2349032ba6e6dd92fe5caa854f4 Mon Sep 17 00:00:00 2001 From: Andrew Sazonov Date: Mon, 11 Aug 2025 17:20:19 +0200 Subject: [PATCH 2/3] Update plot display method to avoid warnings --- .../plotting/plotters/plotter_plotly.py | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/easydiffraction/plotting/plotters/plotter_plotly.py b/src/easydiffraction/plotting/plotters/plotter_plotly.py index e645e6a6..dbf2f05f 100644 --- a/src/easydiffraction/plotting/plotters/plotter_plotly.py +++ b/src/easydiffraction/plotting/plotters/plotter_plotly.py @@ -107,26 +107,20 @@ def plot( # Show the figure - # This can lead to warnings in Jupyter notebooks: - # WARNING: skipping unknown output mime type: application/vnd.plotly.v1+json [mystnb.unknown_mime_type] - if is_notebook() or is_pycharm() or display is None or HTML is None: - print( - f'----DEBUG----: fig.show(): is_notebook()={is_notebook()}, is_pycharm()={is_pycharm()}, ' - f'display={display}, HTML={HTML}' - ) + # The standard `fig.show()` method method triggers the following + # warning during the DMSC Summer School 2025 book build process: + # WARNING: skipping unknown output mime type: + # application/vnd.plotly.v1+json [mystnb.unknown_mime_type] + # So, instead, we will use `pio.to_html()` to convert the figure + # to HTML and keep `fig.show()` in PyCharm only. + + if is_pycharm() or display is None or HTML is None: fig.show(config=config) - - # If IPython is available, we can convert the figure to HTML and - # display it in the notebook. else: - # Convert figure to HTML html_fig = pio.to_html( fig, include_plotlyjs='cdn', full_html=False, config=config, ) - - # Display it in the notebook - print('----DEBUG----: display(HTML(html_fig))') display(HTML(html_fig)) From 64d22c5d741c076e8a6e0b387372b07662b5b580 Mon Sep 17 00:00:00 2001 From: Andrew Sazonov Date: Mon, 11 Aug 2025 17:24:43 +0200 Subject: [PATCH 3/3] Removes unused is_notebook import --- src/easydiffraction/plotting/plotters/plotter_plotly.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/easydiffraction/plotting/plotters/plotter_plotly.py b/src/easydiffraction/plotting/plotters/plotter_plotly.py index dbf2f05f..b8a011be 100644 --- a/src/easydiffraction/plotting/plotters/plotter_plotly.py +++ b/src/easydiffraction/plotting/plotters/plotter_plotly.py @@ -12,7 +12,6 @@ display = None HTML = None -from easydiffraction.utils.utils import is_notebook from easydiffraction.utils.utils import is_pycharm from .plotter_base import SERIES_CONFIG