From f2549c9470efe891baf7c15b59f485a12236a8ea Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 26 Apr 2023 09:48:05 -0500 Subject: [PATCH] Defer a few more matplotlib imports --- openmc/model/surface_composite.py | 2 +- tests/regression_tests/python_import/test.py | 7 ------- tests/test_matplotlib_import.py | 6 ++++++ tests/unit_tests/test_plotter.py | 7 ++++--- 4 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 tests/regression_tests/python_import/test.py create mode 100644 tests/test_matplotlib_import.py diff --git a/openmc/model/surface_composite.py b/openmc/model/surface_composite.py index 25826723c..9508a1db8 100644 --- a/openmc/model/surface_composite.py +++ b/openmc/model/surface_composite.py @@ -6,7 +6,6 @@ import operator import numpy as np from scipy.spatial import ConvexHull, Delaunay -from matplotlib.path import Path import openmc from openmc.checkvalue import (check_greater_than, check_value, @@ -1021,6 +1020,7 @@ class Polygon(CompositeSurface): ------- surfsets : a list of lists of surface, operator pairs """ + from matplotlib.path import Path # Get centroids of all the simplices and determine if they are inside # the polygon defined by input vertices or not. diff --git a/tests/regression_tests/python_import/test.py b/tests/regression_tests/python_import/test.py deleted file mode 100644 index d24a0cae1..000000000 --- a/tests/regression_tests/python_import/test.py +++ /dev/null @@ -1,7 +0,0 @@ -import sys -import openmc - - -def test_matplotlib_presence(): - """Checks that remains a deferred import""" - assert 'matplotlib.pyplot' not in sys.modules diff --git a/tests/test_matplotlib_import.py b/tests/test_matplotlib_import.py new file mode 100644 index 000000000..d319976c4 --- /dev/null +++ b/tests/test_matplotlib_import.py @@ -0,0 +1,6 @@ +import sys +import openmc + +def test_matplotlib_presence(): + """Checks that matplotlib remains a deferred import""" + assert 'matplotlib' not in sys.modules diff --git a/tests/unit_tests/test_plotter.py b/tests/unit_tests/test_plotter.py index cabf9af6d..8520249ba 100644 --- a/tests/unit_tests/test_plotter.py +++ b/tests/unit_tests/test_plotter.py @@ -1,7 +1,6 @@ import numpy as np import openmc import pytest -from matplotlib.figure import Figure @pytest.fixture(scope='module') @@ -74,8 +73,10 @@ def test_calculate_cexs_with_materials(test_mat): @pytest.mark.parametrize("this", ["Be", "Be9"]) def test_plot_xs(this): - assert isinstance(openmc.plotter.plot_xs(this, types=['total']), Figure) + from matplotlib.figure import Figure + assert isinstance(openmc.plot_xs(this, types=['total']), Figure) def test_plot_xs_mat(test_mat): - assert isinstance(openmc.plotter.plot_xs(test_mat, types=['total']), Figure) + from matplotlib.figure import Figure + assert isinstance(openmc.plot_xs(test_mat, types=['total']), Figure)