From 8f36ff2b3a5e2984254f7b21f1b92af7ad18140b Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 23 Sep 2025 10:06:29 -0500 Subject: [PATCH] Update find_package calls in OpenMCConfig.cmake (#3572) --- cmake/OpenMCConfig.cmake.in | 11 +++++++---- openmc/deplete/transfer_rates.py | 2 +- tests/regression_tests/unstructured_mesh/test.py | 2 +- tests/unit_tests/dagmc/test_plot.py | 5 ++++- tests/unit_tests/test_model.py | 4 ++++ tests/unit_tests/test_region.py | 4 ++++ tests/unit_tests/test_universe.py | 4 ++++ tests/unit_tests/weightwindows/test_wwinp_reader.py | 2 +- tools/ci/gha-script.sh | 5 ++++- 9 files changed, 30 insertions(+), 9 deletions(-) diff --git a/cmake/OpenMCConfig.cmake.in b/cmake/OpenMCConfig.cmake.in index 3fe0c1bcd1..837a39c783 100644 --- a/cmake/OpenMCConfig.cmake.in +++ b/cmake/OpenMCConfig.cmake.in @@ -1,9 +1,12 @@ get_filename_component(OpenMC_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) -find_package(fmt REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../fmt) -find_package(pugixml REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../pugixml) -find_package(xtl REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../xtl) -find_package(xtensor REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../xtensor) +# Compute the install prefix from this file's location +get_filename_component(_OPENMC_PREFIX "${OpenMC_CMAKE_DIR}/../../.." ABSOLUTE) + +find_package(fmt CONFIG REQUIRED HINTS ${_OPENMC_PREFIX}) +find_package(pugixml CONFIG REQUIRED HINTS ${_OPENMC_PREFIX}) +find_package(xtl CONFIG REQUIRED HINTS ${_OPENMC_PREFIX}) +find_package(xtensor CONFIG REQUIRED HINTS ${_OPENMC_PREFIX}) if(@OPENMC_USE_DAGMC@) find_package(DAGMC REQUIRED HINTS @DAGMC_DIR@) endif() diff --git a/openmc/deplete/transfer_rates.py b/openmc/deplete/transfer_rates.py index 4c28c7d150..4f2b9aba5f 100644 --- a/openmc/deplete/transfer_rates.py +++ b/openmc/deplete/transfer_rates.py @@ -366,7 +366,7 @@ class ExternalSourceRates(ExternalRates): rate : float External source rate in units of mass per time. A positive or negative value corresponds to a feed or removal rate, respectively. - units : {'g/s', 'g/min', 'g/h', 'g/d', 'g/a'} + rate_units : {'g/s', 'g/min', 'g/h', 'g/d', 'g/a'} Units for values specified in the `rate` argument. 's' for seconds, 'min' for minutes, 'h' for hours, 'a' for Julian years. timesteps : list of int, optional diff --git a/tests/regression_tests/unstructured_mesh/test.py b/tests/regression_tests/unstructured_mesh/test.py index 0082198dde..7607531d8b 100644 --- a/tests/regression_tests/unstructured_mesh/test.py +++ b/tests/regression_tests/unstructured_mesh/test.py @@ -256,7 +256,7 @@ for i, (lib, estimator, ext_geom, holes) in enumerate(product(*param_values)): def test_unstructured_mesh_tets(model, test_opts): # skip the test if the library is not enabled if test_opts['library'] == 'moab' and not openmc.lib._dagmc_enabled(): - pytest.skip("DAGMC (and MOAB) mesh not enbaled in this build.") + pytest.skip("DAGMC (and MOAB) mesh not enabled in this build.") if test_opts['library'] == 'libmesh' and not openmc.lib._libmesh_enabled(): pytest.skip("LibMesh is not enabled in this build.") diff --git a/tests/unit_tests/dagmc/test_plot.py b/tests/unit_tests/dagmc/test_plot.py index 62022b2583..6ce1d79a22 100644 --- a/tests/unit_tests/dagmc/test_plot.py +++ b/tests/unit_tests/dagmc/test_plot.py @@ -64,5 +64,8 @@ def test_plotting_geometry_filled_with_dagmc_universe(request): cell2 = openmc.Cell(fill=csg_material, region=+sphere1 & -sphere2) geometry = openmc.Geometry([cell1, cell2]) - geometry.plot() + + # Close plot to avoid warning + import matplotlib.pyplot as plt + plt.close() diff --git a/tests/unit_tests/test_model.py b/tests/unit_tests/test_model.py index 12f0df6c9e..60f8b1a25a 100644 --- a/tests/unit_tests/test_model.py +++ b/tests/unit_tests/test_model.py @@ -654,6 +654,10 @@ def test_model_plot(): test_mask = (image_data == white) | (image_data == red) assert np.all(test_mask), "Colors other than white or red found in overlap plot image" + # Close plots to avoid warning + import matplotlib.pyplot as plt + plt.close('all') + def test_model_id_map_initialization(run_in_tmpdir): model = openmc.examples.pwr_assembly() diff --git a/tests/unit_tests/test_region.py b/tests/unit_tests/test_region.py index cbcd198312..cb9fa171bb 100644 --- a/tests/unit_tests/test_region.py +++ b/tests/unit_tests/test_region.py @@ -248,6 +248,10 @@ def test_plot(): c_before = openmc.Cell() region.plot() + # Close plot to avoid warning + import matplotlib.pyplot as plt + plt.close() + # Ensure that calling plot doesn't affect cell ID space c_after = openmc.Cell() assert c_after.id - 1 == c_before.id diff --git a/tests/unit_tests/test_universe.py b/tests/unit_tests/test_universe.py index 46d4ec3f73..efe8552a64 100644 --- a/tests/unit_tests/test_universe.py +++ b/tests/unit_tests/test_universe.py @@ -99,6 +99,10 @@ def test_plot(run_in_tmpdir, sphere_model): pixels=100, ) + # Close plots to avoid warning + import matplotlib.pyplot as plt + plt.close('all') + def test_get_nuclides(uo2): c = openmc.Cell(fill=uo2) diff --git a/tests/unit_tests/weightwindows/test_wwinp_reader.py b/tests/unit_tests/weightwindows/test_wwinp_reader.py index 28548a4486..637463bb2e 100644 --- a/tests/unit_tests/weightwindows/test_wwinp_reader.py +++ b/tests/unit_tests/weightwindows/test_wwinp_reader.py @@ -140,4 +140,4 @@ def test_wwinp_reader_failures(wwinp_data, request): filename, expected_failure = wwinp_data with pytest.raises(expected_failure): - _ = openmc.wwinp_to_wws(request.node.path.parent / filename) + _ = openmc.WeightWindowsList.from_wwinp(request.node.path.parent / filename) diff --git a/tools/ci/gha-script.sh b/tools/ci/gha-script.sh index c0f754c32c..c1d2921377 100755 --- a/tools/ci/gha-script.sh +++ b/tools/ci/gha-script.sh @@ -15,4 +15,7 @@ if [[ $EVENT == 'y' ]]; then fi # Run unit tests and then regression tests -pytest --cov=openmc -v $args tests/unit_tests tests/regression_tests +pytest --cov=openmc -v $args \ + tests/test_matplotlib_import.py \ + tests/unit_tests \ + tests/regression_tests