open-atmos / devops_tests

pytest test routines asserting for GitHub issue-linked TODO labelling in the code, README link consistency and some Jupyter notebook sanity checks
GNU General Public License v3.0
0 stars 2 forks source link

check all notebooks use show_plot() is plotting (svg, download button, ...) #10

Closed slayoo closed 5 months ago

slayoo commented 1 year ago

something like this should do:

@staticmethod
def test_show_plot_used_if_notebook_uses_matplotlib(notebook):
    """ checks if all notebooks use the open-atmos-jupyter-utils show_plot instead of pyplot.show() """
    with open(notebook) as fp:
        nb = nbformat.read(fp, nbformat.NO_CONVERT)
        matplotlib_used = False
        show_plot_used = False
        for cell in nb.cells:
            if cell.cell_type == "code":
                if "matplotlib" in cell.source:
                    matplotlib_used = True
                if "import open_atmos_jupyter_utils" in cell.source or "from open_atmos_jupyter_utils" in cell.source:
                    show_plot_used = True
        if matplotlib_used and not show_plot_used:
            raise AssertionError("if using matplotlib, please use open_atmos_jupyter_utils.show_plot()")
slayoo commented 1 year ago

should fail on PyMPDATA_examples/Olesik_et_al_2022/demo_analytical_solution.ipynb

github-actions[bot] commented 1 year ago

Stale issue message

github-actions[bot] commented 12 months ago

Stale issue message

github-actions[bot] commented 9 months ago

Stale issue message

github-actions[bot] commented 6 months ago

Stale issue message