Skip to content

Commit

Permalink
[skip ci] Apply formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell authored and github-actions[bot] committed Mar 1, 2024
1 parent c7a0d70 commit 7552ace
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/openmc_source_plotter/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def plot_source_energy(
xaxis_units: The units to use for the x axis. Options are 'eV' or 'MeV'.
"""

if xaxis_units not in ['eV', 'MeV']:
if xaxis_units not in ["eV", "MeV"]:
raise ValueError(f"xaxis_units must be either 'eV' or 'MeV' not {xaxis_units}")

if figure is None:
Expand All @@ -121,8 +121,8 @@ def plot_source_energy(
if isinstance(self, openmc.SourceBase):
probability = probability * self.strength
energy = bin_edges[:-1]
if xaxis_units == 'MeV':
energy = energy /1e6
if xaxis_units == "MeV":
energy = energy / 1e6
# Plot source energy histogram
figure.add_trace(
plotly.graph_objects.Scatter(
Expand Down
9 changes: 7 additions & 2 deletions tests/test_core_with_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ def test_energy_plot(test_source):
assert isinstance(plot, go.Figure)
assert len(plot.data[0]["x"]) == 1


def test_energy_plot_axis(test_source):
plot = test_source.plot_source_energy(n_samples=10, xaxis_type='log', yaxis_type='linear', xaxis_units='eV')
plot = test_source.plot_source_energy(n_samples=10, xaxis_type='linear', yaxis_type='log', xaxis_units='MeV')
plot = test_source.plot_source_energy(
n_samples=10, xaxis_type="log", yaxis_type="linear", xaxis_units="eV"
)
plot = test_source.plot_source_energy(
n_samples=10, xaxis_type="linear", yaxis_type="log", xaxis_units="MeV"
)
assert isinstance(plot, go.Figure)
assert len(plot.data[0]["x"]) == 1

Expand Down

0 comments on commit 7552ace

Please sign in to comment.