Skip to content

Commit 958af49

Browse files
authored
Merge pull request #66 from fusion-energy/adding_error_if_outline_but_no_geometry
added warning for outline usage and sorted imports
2 parents ee29b49 + 893acfe commit 958af49

File tree

8 files changed

+24
-16
lines changed

8 files changed

+24
-16
lines changed

examples/plot_minimal_2d_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import openmc
22
from matplotlib.colors import LogNorm
3-
from openmc_regular_mesh_plotter import plot_mesh_tally
43

4+
from openmc_regular_mesh_plotter import plot_mesh_tally
55

66
# MATERIALS
77
mat_1 = openmc.Material()

examples/plot_minimal_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import openmc
22
from matplotlib.colors import LogNorm
3-
from openmc_regular_mesh_plotter import plot_mesh_tally
43

4+
from openmc_regular_mesh_plotter import plot_mesh_tally
55

66
# MATERIALS
77
mat_1 = openmc.Material()

examples/plot_sweep_through_slice_indexes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
# It is also set up to accept any geometry and the mesh tally will adapt to the geometry dimensions
33

44

5-
import openmc
5+
import matplotlib
66
import numpy as np
7+
import openmc
8+
from matplotlib import cm
79
from matplotlib.colors import LogNorm
10+
811
from openmc_regular_mesh_plotter import plot_mesh_tally
9-
from matplotlib import cm
10-
import matplotlib
1112

1213
# sets the font for the axis
1314
matplotlib.rc("font", **{"family": "normal", "size": 22})

examples/plot_two_tallies_combined.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import openmc
22
from matplotlib.colors import LogNorm
3-
from openmc_regular_mesh_plotter import plot_mesh_tally
43

4+
from openmc_regular_mesh_plotter import plot_mesh_tally
55

66
# MATERIALS
77
mat_1 = openmc.Material()

examples/plot_with_custom_color_map.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# It is also set up to accept any geometry and the mesh tally will adapt to the geometry dimensions
33

44

5+
import matplotlib.pyplot as plt
56
import openmc
6-
from matplotlib.colors import LogNorm
7-
from openmc_regular_mesh_plotter import plot_mesh_tally
87
from matplotlib import cm
9-
import matplotlib.pyplot as plt
8+
from matplotlib.colors import LogNorm
109

10+
from openmc_regular_mesh_plotter import plot_mesh_tally
1111

1212
# materials
1313
mat_concrete = openmc.Material()

src/openmc_regular_mesh_plotter/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
try:
2-
from importlib.metadata import version, PackageNotFoundError
2+
from importlib.metadata import PackageNotFoundError, version
33
except (ModuleNotFoundError, ImportError):
4-
from importlib_metadata import version, PackageNotFoundError
4+
from importlib_metadata import PackageNotFoundError, version
55
try:
66
__version__ = version("openmc_regular_mesh_plotter")
77
except PackageNotFoundError:

src/openmc_regular_mesh_plotter/core.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import math
2+
import typing
23
from pathlib import Path
34
from tempfile import TemporaryDirectory
4-
import typing
5-
import openmc
5+
6+
import matplotlib.pyplot as plt
67
import numpy as np
78
import openmc
89
import openmc.checkvalue as cv
9-
import matplotlib.pyplot as plt
10-
1110
from packaging import version
1211

1312
if version.parse(openmc.__version__) < version.parse("0.13.3"):
@@ -182,6 +181,13 @@ def plot_mesh_tally(
182181
if colorbar:
183182
fig.colorbar(im, **colorbar_kwargs)
184183

184+
if outline and geometry is None:
185+
msg = (
186+
"When calling plot_mesh_tally with outline=True the geometry "
187+
"should also be provided. Either set outline to False or set "
188+
"the geometry to and openmc.Geometry object"
189+
)
190+
raise ValueError(msg)
185191
if outline and geometry is not None:
186192
import matplotlib.image as mpimg
187193

tests/test_units.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import openmc
2+
import pytest
23
from matplotlib.colors import LogNorm
4+
35
from openmc_regular_mesh_plotter import plot_mesh_tally
4-
import pytest
56

67

78
@pytest.fixture()

0 commit comments

Comments
 (0)