From 60a2ff1fc181c051e54d42f0d65b18da0871b31c Mon Sep 17 00:00:00 2001 From: "Labossiere-Hickman, Travis James" Date: Fri, 17 Jul 2026 10:01:16 -0600 Subject: [PATCH] This belongs in test_filter_mesh --- tests/unit_tests/test_filter_mesh.py | 42 ++++++++++++++++++++++++++++ tests/unit_tests/test_mesh.py | 42 ---------------------------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/tests/unit_tests/test_filter_mesh.py b/tests/unit_tests/test_filter_mesh.py index e26bea337b..5f68de293d 100644 --- a/tests/unit_tests/test_filter_mesh.py +++ b/tests/unit_tests/test_filter_mesh.py @@ -410,3 +410,45 @@ def test_mesh_filter_dataframe_rectilinear(): assert (mesh_key, 'y') in df.columns assert (mesh_key, 'z') in df.columns assert len(df) == data_size + + +@pytest.mark.parametrize('mesh_type', ('regular', 'rectilinear', 'cylindrical', 'spherical')) +def test_axis_labels(mesh_type): + if mesh_type == 'regular': + mesh = openmc.RegularMesh() + mesh.lower_left = np.asarray([0.0]*3] + mesh.width = np.asarray([0.0]*3] + mesh.dimension = (1, 1, 1) + elif mesh_type == 'rectilinear': + mesh = openmc.RectilinearMesh() + mesh.x_grid = np.asarray([0.0, 1.0]) + mesh.y_grid = np.asarray([0.0, 1.0]) + mesh.z_grid = np.asarray([0.0, 1.0]) + elif mesh_type == 'cylindrical': + r_grid = np.asarray([0.0, 1.0]) + z_grid = np.asarray([0.0, 1.0]) + p_grid = np.asarray([0.0, 1.0]) + mesh = openmc.CylindricalMesh(r_grid=r_grid, z_grid=z_grid, phi_grid=p_grid) + elif mesh_type == 'spherical': + r_grid = np.asarray([0.0, 1.0]) + t_grid = np.asarray([0.0, 1.0]) + p_grid = np.asarray([0.0, 1.0]) + mesh = openmc.SphericalMesh(r_grid=r_grid, theta_grid=t_grid, phi_grid=p_grid) + else: + raise ValueError(mesh_type) + + filt = openmc.MeshSurfaceFilter(mesh) + assert len(filt.bins) == 12 + bin_names = [b[3] for b in filt.bins] + if mesh_type in {'regular', 'rectilinear'}: + assert bin_names[:8] == ['x-min out', 'x-min in', 'x-max out', 'x-max in', + 'y-min out', 'y-min in', 'y-max out', 'y-max in'] + if mesh_type in {'regular', 'rectilinear', 'cylindrical'}: + assert bin_names[8:] == ['z-min out', 'z-min in', 'z-max out', 'z-max in'] + if mesh_type in {'cylindrical', 'spherical'}: + assert bin_names[:4] == ['r-min out', 'r-min in', 'r-max out', 'r-max in'] + if mesh_type == 'spherical': + assert bin_names[4:] == ['theta-min out', 'theta-min in', 'theta-max out', 'theta-max in', + 'phi-min out', 'phi-min in', 'phi-max out', 'phi-max in'] + if mesh_type == 'cylindrical': + assert bin_names[4:8] == ['phi-min out', 'phi-min in', 'phi-max out', 'phi-max in'] diff --git a/tests/unit_tests/test_mesh.py b/tests/unit_tests/test_mesh.py index 12df74ae6a..9b1469fc59 100644 --- a/tests/unit_tests/test_mesh.py +++ b/tests/unit_tests/test_mesh.py @@ -267,48 +267,6 @@ def test_centroids(): np.testing.assert_array_almost_equal(mesh.centroids[0, 0, 0], [x-5.0, y-5.0, z+5.0]) -@pytest.mark.parametrize('mesh_type', ('regular', 'rectilinear', 'cylindrical', 'spherical')) -def test_axis_labels(mesh_type): - if mesh_type == 'regular': - mesh = openmc.RegularMesh() - mesh.lower_left = np.asarray([0.0]*3] - mesh.width = np.asarray([0.0]*3] - mesh.dimension = (1, 1, 1) - elif mesh_type == 'rectilinear': - mesh = openmc.RectilinearMesh() - mesh.x_grid = np.asarray([0.0, 1.0]) - mesh.y_grid = np.asarray([0.0, 1.0]) - mesh.z_grid = np.asarray([0.0, 1.0]) - elif mesh_type == 'cylindrical': - r_grid = np.asarray([0.0, 1.0]) - z_grid = np.asarray([0.0, 1.0]) - p_grid = np.asarray([0.0, 1.0]) - mesh = openmc.CylindricalMesh(r_grid=r_grid, z_grid=z_grid, phi_grid=p_grid) - elif mesh_type == 'spherical': - r_grid = np.asarray([0.0, 1.0]) - t_grid = np.asarray([0.0, 1.0]) - p_grid = np.asarray([0.0, 1.0]) - mesh = openmc.SphericalMesh(r_grid=r_grid, theta_grid=t_grid, phi_grid=p_grid) - else: - raise ValueError(mesh_type) - - filt = openmc.MeshSurfaceFilter(mesh) - assert len(filt.bins) == 12 - bin_names = [b[3] for b in filt.bins] - if mesh_type in {'regular', 'rectilinear'}: - assert bin_names[:8] == ['x-min out', 'x-min in', 'x-max out', 'x-max in', - 'y-min out', 'y-min in', 'y-max out', 'y-max in'] - if mesh_type in {'regular', 'rectilinear', 'cylindrical'}: - assert bin_names[8:] == ['z-min out', 'z-min in', 'z-max out', 'z-max in'] - if mesh_type in {'cylindrical', 'spherical'}: - assert bin_names[:4] == ['r-min out', 'r-min in', 'r-max out', 'r-max in'] - if mesh_type == 'spherical': - assert bin_names[4:] == ['theta-min out', 'theta-min in', 'theta-max out', 'theta-max in', - 'phi-min out', 'phi-min in', 'phi-max out', 'phi-max in'] - if mesh_type == 'cylindrical': - assert bin_names[4:8] == ['phi-min out', 'phi-min in', 'phi-max out', 'phi-max in'] - - @pytest.mark.parametrize('mesh_type', ('regular', 'rectilinear', 'cylindrical', 'spherical')) def test_mesh_vertices(mesh_type):