Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added warning for outline usage and sorted imports #66

Merged
merged 4 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading