diff --git a/examples/plot_minimal_2d_example.py b/examples/plot_minimal_2d_example.py index f290368..1af84b1 100644 --- a/examples/plot_minimal_2d_example.py +++ b/examples/plot_minimal_2d_example.py @@ -1,7 +1,7 @@ import openmc from matplotlib.colors import LogNorm -from openmc_regular_mesh_plotter import plot_mesh_tally +from openmc_regular_mesh_plotter import plot_mesh_tally # MATERIALS mat_1 = openmc.Material() diff --git a/examples/plot_minimal_example.py b/examples/plot_minimal_example.py index 04342ee..f6bedaf 100644 --- a/examples/plot_minimal_example.py +++ b/examples/plot_minimal_example.py @@ -1,7 +1,7 @@ import openmc from matplotlib.colors import LogNorm -from openmc_regular_mesh_plotter import plot_mesh_tally +from openmc_regular_mesh_plotter import plot_mesh_tally # MATERIALS mat_1 = openmc.Material() diff --git a/examples/plot_sweep_through_slice_indexes.py b/examples/plot_sweep_through_slice_indexes.py index 9c321f2..a3dd299 100644 --- a/examples/plot_sweep_through_slice_indexes.py +++ b/examples/plot_sweep_through_slice_indexes.py @@ -2,12 +2,13 @@ # It is also set up to accept any geometry and the mesh tally will adapt to the geometry dimensions -import openmc +import matplotlib import numpy as np +import openmc +from matplotlib import cm from matplotlib.colors import LogNorm + from openmc_regular_mesh_plotter import plot_mesh_tally -from matplotlib import cm -import matplotlib # sets the font for the axis matplotlib.rc("font", **{"family": "normal", "size": 22}) diff --git a/examples/plot_two_tallies_combined.py b/examples/plot_two_tallies_combined.py index 10d6c87..fe6af27 100644 --- a/examples/plot_two_tallies_combined.py +++ b/examples/plot_two_tallies_combined.py @@ -1,7 +1,7 @@ import openmc from matplotlib.colors import LogNorm -from openmc_regular_mesh_plotter import plot_mesh_tally +from openmc_regular_mesh_plotter import plot_mesh_tally # MATERIALS mat_1 = openmc.Material() diff --git a/examples/plot_with_custom_color_map.py b/examples/plot_with_custom_color_map.py index cdac48a..a5ae7af 100644 --- a/examples/plot_with_custom_color_map.py +++ b/examples/plot_with_custom_color_map.py @@ -2,12 +2,12 @@ # It is also set up to accept any geometry and the mesh tally will adapt to the geometry dimensions +import matplotlib.pyplot as plt import openmc -from matplotlib.colors import LogNorm -from openmc_regular_mesh_plotter import plot_mesh_tally from matplotlib import cm -import matplotlib.pyplot as plt +from matplotlib.colors import LogNorm +from openmc_regular_mesh_plotter import plot_mesh_tally # materials mat_concrete = openmc.Material() diff --git a/src/openmc_regular_mesh_plotter/__init__.py b/src/openmc_regular_mesh_plotter/__init__.py index dd0f602..146eafb 100644 --- a/src/openmc_regular_mesh_plotter/__init__.py +++ b/src/openmc_regular_mesh_plotter/__init__.py @@ -1,7 +1,7 @@ try: - from importlib.metadata import version, PackageNotFoundError + from importlib.metadata import PackageNotFoundError, version except (ModuleNotFoundError, ImportError): - from importlib_metadata import version, PackageNotFoundError + from importlib_metadata import PackageNotFoundError, version try: __version__ = version("openmc_regular_mesh_plotter") except PackageNotFoundError: diff --git a/src/openmc_regular_mesh_plotter/core.py b/src/openmc_regular_mesh_plotter/core.py index b42b905..0d3264b 100644 --- a/src/openmc_regular_mesh_plotter/core.py +++ b/src/openmc_regular_mesh_plotter/core.py @@ -1,13 +1,12 @@ import math +import typing from pathlib import Path from tempfile import TemporaryDirectory -import typing -import openmc + +import matplotlib.pyplot as plt import numpy as np import openmc import openmc.checkvalue as cv -import matplotlib.pyplot as plt - from packaging import version if version.parse(openmc.__version__) < version.parse("0.13.3"): @@ -182,6 +181,13 @@ def plot_mesh_tally( if colorbar: fig.colorbar(im, **colorbar_kwargs) + if outline and geometry is None: + msg = ( + "When calling plot_mesh_tally with outline=True the geometry " + "should also be provided. Either set outline to False or set " + "the geometry to and openmc.Geometry object" + ) + raise ValueError(msg) if outline and geometry is not None: import matplotlib.image as mpimg diff --git a/tests/test_units.py b/tests/test_units.py index df33329..e6b9826 100644 --- a/tests/test_units.py +++ b/tests/test_units.py @@ -1,7 +1,8 @@ import openmc +import pytest from matplotlib.colors import LogNorm + from openmc_regular_mesh_plotter import plot_mesh_tally -import pytest @pytest.fixture()