Skip to content

Commit

Permalink
updated tests to use functions
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Mar 5, 2024
1 parent a042c8b commit a63f259
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_with_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
image: openmc/openmc:develop
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: install package
run: |
Expand Down
1 change: 1 addition & 0 deletions tests/test_core_with_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
sample_initial_particles,
plot_source_energy,
plot_source_position,
plot_source_direction
)
import numpy as np
import plotly.graph_objects as go
Expand Down
29 changes: 17 additions & 12 deletions tests/test_core_with_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_source():


def test_sample_initial_particles(test_source):
particles = test_source.sample_initial_particles(n_samples=42)
particles = sample_initial_particles(this=test_source, n_samples=42)
for particle in particles:
assert particle.E == 14e6
assert str(particle.particle) == "neutron"
Expand All @@ -40,54 +40,59 @@ def test_sample_initial_particles(test_source):


def test_energy_plot_with_bins(test_source):
plot = test_source.plot_source_energy(
plot = plot_source_energy(
this=test_source,
n_samples=10,
energy_bins=np.linspace(0, 20e6, 100),
)
assert isinstance(plot, go.Figure)


def test_energy_plot(test_source):
plot = test_source.plot_source_energy(n_samples=10)
plot = plot_source_energy(this=test_source, n_samples=10)
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 = plot_source_energy(
this=test_source,
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 = plot_source_energy(
this=test_source, n_samples=10, xaxis_type="linear", yaxis_type="log", xaxis_units="MeV"
)
assert isinstance(plot, go.Figure)
assert len(plot.data[0]["x"]) == 1


def test_position_plot(test_source):
plot = test_source.plot_source_position(n_samples=10)
plot = plot_source_position(this=test_source, n_samples=10)
assert isinstance(plot, go.Figure)


def test_direction_plot(test_source):
plot = test_source.plot_source_direction(n_samples=10)
plot = plot_source_direction(this=test_source, n_samples=10)
assert isinstance(plot, go.Figure)


def test_energy_plot_with_figure(test_source):
base_figure = go.Figure()
plot = test_source.plot_source_energy(figure=base_figure, n_samples=10)
plot = plot_source_energy(this=test_source, figure=base_figure, n_samples=10)
assert isinstance(plot, go.Figure)
assert len(plot.data[0]["x"]) == 1


def test_position_plot_with_figure(test_source):
base_figure = go.Figure()
plot = test_source.plot_source_position(figure=base_figure, n_samples=10)
plot = plot_source_position(this=test_source, figure=base_figure, n_samples=10)
assert isinstance(plot, go.Figure)


def test_direction_plot_with_figure(test_source):
base_figure = go.Figure()
plot = test_source.plot_source_direction(figure=base_figure, n_samples=10)
plot = plot_source_direction(this=test_source, figure=base_figure, n_samples=10)
assert isinstance(plot, go.Figure)

0 comments on commit a63f259

Please sign in to comment.