Skip to content

Commit

Permalink
Merge pull request #66 from fusion-energy/adding_error_if_outline_but…
Browse files Browse the repository at this point in the history
…_no_geometry

added warning for outline usage and sorted imports
  • Loading branch information
shimwell authored May 9, 2024
2 parents ee29b49 + 893acfe commit 958af49
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion examples/plot_minimal_2d_example.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_minimal_example.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
7 changes: 4 additions & 3 deletions examples/plot_sweep_through_slice_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_two_tallies_combined.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
6 changes: 3 additions & 3 deletions examples/plot_with_custom_color_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/openmc_regular_mesh_plotter/__init__.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
14 changes: 10 additions & 4 deletions src/openmc_regular_mesh_plotter/core.py
Original file line number Diff line number Diff line change
@@ -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"):
Expand Down Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion tests/test_units.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down

0 comments on commit 958af49

Please sign in to comment.