From 2a4034abb23614869e43d757d5a6e769b5ff438c Mon Sep 17 00:00:00 2001 From: Nathan Glaser Date: Wed, 29 Apr 2026 18:14:27 -0700 Subject: [PATCH 1/4] change from os call to subprocess --- test/unit/run.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/unit/run.py b/test/unit/run.py index a445eabc8..55d55be6d 100644 --- a/test/unit/run.py +++ b/test/unit/run.py @@ -1,4 +1,5 @@ import time, os, sys +import subprocess from pathlib import Path # Get all the test file paths @@ -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 @@ -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 @@ -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) From 0037c9a1389da5d2d9fa6c946bbfff4404ce866a Mon Sep 17 00:00:00 2001 From: Nathan Glaser Date: Wed, 29 Apr 2026 18:20:26 -0700 Subject: [PATCH 2/4] update energy deposition object unit test --- test/unit/object_/tally/energy_deposition.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/object_/tally/energy_deposition.py b/test/unit/object_/tally/energy_deposition.py index 673d91cfc..1cf988d20 100644 --- a/test/unit/object_/tally/energy_deposition.py +++ b/test/unit/object_/tally/energy_deposition.py @@ -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 From 57005507e2408a073d235d59b29c2a91ede09c99 Mon Sep 17 00:00:00 2001 From: Nathan Glaser Date: Wed, 29 Apr 2026 18:27:57 -0700 Subject: [PATCH 3/4] update test_multi_table --- test/unit/transport/distributions/test_multi_table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/transport/distributions/test_multi_table.py b/test/unit/transport/distributions/test_multi_table.py index 102a9e5a9..d1a750758 100644 --- a/test/unit/transport/distributions/test_multi_table.py +++ b/test/unit/transport/distributions/test_multi_table.py @@ -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. From 7611f0eb538402e099d63e5bf9793b0a86de7afc Mon Sep 17 00:00:00 2001 From: Nathan Glaser Date: Wed, 29 Apr 2026 18:32:08 -0700 Subject: [PATCH 4/4] update find_bin unit tests --- test/unit/transport/util/find_bin.py | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/test/unit/transport/util/find_bin.py b/test/unit/transport/util/find_bin.py index f864a5e48..4bdc9dc32 100644 --- a/test/unit/transport/util/find_bin.py +++ b/test/unit/transport/util/find_bin.py @@ -3,7 +3,7 @@ #### -from mcdc.transport.util import find_bin +from mcdc.transport.util import find_bin, find_bin_with_rules @pytest.fixture @@ -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):