Skip to content
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
3 changes: 2 additions & 1 deletion test/unit/object_/tally/energy_deposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ def test_edep_cannot_be_grouped_with_other_scores(capsys):
mcdc.Tally(mesh=mesh, scores=["flux", "energy_deposition"])

captured = capsys.readouterr()
assert "cannot be grouped with other scores yet" in captured.out
assert "Cannot mix tracklength scores with collision ones" in captured.out
assert "energy_deposition" in captured.out
11 changes: 10 additions & 1 deletion test/unit/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import time, os, sys
import subprocess
from pathlib import Path

# Get all the test file paths
Expand All @@ -8,6 +9,8 @@
EXCLUDE = {"run.py", "__pycache__", ".git", "conftest.py", "__init__.py"}
EXCLUDE_PREFIX = {"make_test_"}

failed = False

start = time.perf_counter()
for path in paths:
# Skip exact matches
Expand All @@ -21,7 +24,10 @@

print(f"\nRunning {str(path)}")
sys.stdout.flush()
os.system(f"pytest -q {str(path)}")
result = subprocess.run(["pytest", "-q", str(path)])
if result.returncode != 0:
failed = True # makes sure all tests are run

end = time.perf_counter()
total_time = end - start

Expand All @@ -36,3 +42,6 @@
print(f"\nTotal unit test runtime: {total_time:.3f} minutes")
else:
print(f"\nTotal unit test runtime: {total_time:.3f} seconds")

if failed:
sys.exit(1)
2 changes: 1 addition & 1 deletion test/unit/transport/distributions/test_multi_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_multi_table_distribution_sample(rng_sequence, rng_state):
# xi_2 = 0.3 < r, so Eq. (2.64) selects l = i + 1, i.e. the second table.
rng_sequence([0.3, 0.2])

sampled_E = dist.sample_multi_table(2.0, rng_state, multi_table, data, scale=True)
sampled_E = dist._sample_multi_table(2.0, rng_state, multi_table, data, scale=True)

# In the selected table, xi_1 = 0.2 falls in the first continuous bin.
# Eq. (2.65) gives E' = E_l,k + (xi_1 - c_l,k) / p_l,k = 100 + 0.2 / 0.01 = 120.
Expand Down
34 changes: 17 additions & 17 deletions test/unit/transport/util/find_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

####

from mcdc.transport.util import find_bin
from mcdc.transport.util import find_bin, find_bin_with_rules


@pytest.fixture
Expand All @@ -24,37 +24,37 @@ def test_inside_bins(grid):


def test_exact_interior_edges(grid):
assert find_bin(1.0, grid, 0.0, True) == 0
assert find_bin(1.0, grid, 0.0, False) == 1
assert find_bin(5.0, grid, 0.0, True) == 2
assert find_bin(5.0, grid, 0.0, False) == 3
assert find_bin_with_rules(1.0, grid, 0.0, True) == 0
assert find_bin_with_rules(1.0, grid, 0.0, False) == 1
assert find_bin_with_rules(5.0, grid, 0.0, True) == 2
assert find_bin_with_rules(5.0, grid, 0.0, False) == 3


def test_first_edge(grid):
assert find_bin(0.0, grid, 0.0, True) == -1
assert find_bin(0.0, grid, 0.0, False) == 0
assert find_bin_with_rules(0.0, grid, 0.0, True) == -1
assert find_bin_with_rules(0.0, grid, 0.0, False) == 0


def test_last_edge(grid):
assert find_bin(10.0, grid, 0.0, True) == 3
assert find_bin(10.0, grid, 0.0, False) == -1
assert find_bin_with_rules(10.0, grid, 0.0, True) == 3
assert find_bin_with_rules(10.0, grid, 0.0, False) == -1


def test_near_interior_edges_with_epsilon(grid, eps):
assert find_bin(1.0 - 1e-6, grid, eps, True) == 0
assert find_bin(1.0 - 1e-6, grid, eps, False) == 1
assert find_bin(1.0 + 1e-6, grid, eps, True) == 0
assert find_bin(1.0 + 1e-6, grid, eps, False) == 1
assert find_bin_with_rules(1.0 - 1e-6, grid, eps, True) == 0
assert find_bin_with_rules(1.0 - 1e-6, grid, eps, False) == 1
assert find_bin_with_rules(1.0 + 1e-6, grid, eps, True) == 0
assert find_bin_with_rules(1.0 + 1e-6, grid, eps, False) == 1


def test_near_first_edge_with_epsilon(grid, eps):
assert find_bin(0.0 + 1e-6, grid, eps, True) == -1
assert find_bin(0.0 + 1e-6, grid, eps, False) == 0
assert find_bin_with_rules(0.0 + 1e-6, grid, eps, True) == -1
assert find_bin_with_rules(0.0 + 1e-6, grid, eps, False) == 0


def test_near_last_edge_with_epsilon(grid, eps):
assert find_bin(10.0 - 1e-6, grid, eps, True) == 3
assert find_bin(10.0 - 1e-6, grid, eps, False) == -1
assert find_bin_with_rules(10.0 - 1e-6, grid, eps, True) == 3
assert find_bin_with_rules(10.0 - 1e-6, grid, eps, False) == -1


def test_out_of_range(grid):
Expand Down
Loading