diff --git a/docs/examples/npintensity.py b/docs/examples/npintensity.py index 09a0cb26..5cd0f920 100644 --- a/docs/examples/npintensity.py +++ b/docs/examples/npintensity.py @@ -493,7 +493,7 @@ def makeData(strufile, q, datname, scale, a, Uiso, sig, bkgc, nl=1): S.read(str(strufile)) # Set the lattice parameters - S.lattice.setLatPar(a, a, a) + S.lattice.set_latt_parms(a, a, a) # Set a DW factor for a in S: diff --git a/news/fix-warnings.rst b/news/fix-warnings.rst new file mode 100644 index 00000000..c6c87bf9 --- /dev/null +++ b/news/fix-warnings.rst @@ -0,0 +1,23 @@ +**Added:** + +* No news added: Silence warnings raised during testing and use set_latt_parms in place of the deprecated setLatPar in the tests and npintensity example. + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/tests/test_characteristicfunctions.py b/tests/test_characteristicfunctions.py index 98c8c4ab..3654b953 100644 --- a/tests/test_characteristicfunctions.py +++ b/tests/test_characteristicfunctions.py @@ -818,7 +818,10 @@ def test_deprecated_functions_forward_non_physical_input( ): old_function = getattr(cf, old_name) new_function = getattr(cf, new_name) - expected_characteristic_function = new_function(*new_args) + # Catch the RuntimeWarning to prevent warnings when tests run. + # This test passes non-phyiscal inputs so this behavior is expected here. + with pytest.warns(RuntimeWarning): + expected_characteristic_function = new_function(*new_args) # The oracle call above already consumed the once-per-process # RuntimeWarning for this (function, requirement) pair; clear the diff --git a/tests/test_diffpyparset.py b/tests/test_diffpyparset.py index cecda1cf..49a4231f 100644 --- a/tests/test_diffpyparset.py +++ b/tests/test_diffpyparset.py @@ -82,7 +82,7 @@ def _testLattice(): a1.xyz[1] = 0.123 a1.U11 = 0.321 a1.B32 = 0.111 - dsstru.lattice.setLatPar(a=3.0, gamma=121) + dsstru.lattice.set_latt_parms(a=3.0, gamma=121) _testAtoms() _testLattice() diff --git a/tests/test_fitrecipe.py b/tests/test_fitrecipe.py index e8af724c..69998151 100644 --- a/tests/test_fitrecipe.py +++ b/tests/test_fitrecipe.py @@ -529,9 +529,13 @@ def test_initialize_recipe_from_results_object(build_recipes_one_contribution): assert actual_names_before_init == expected_names_before_init recipe2.initialize_recipe_with_results(results1) optimize_recipe(recipe2) + # Fix extra_var to prevent divide by zero warnings when tests run. + recipe2.fix("extra_var") results2 = FitResults(recipe2) - actual_values = sorted(np.round(results2.varvals, 5).tolist()) - actual_names = sorted(results2.varnames) + actual_values = sorted( + np.round(np.append(results2.varvals, results2.fixedvals), 5).tolist() + ) + actual_names = sorted(results2.varnames + results2.fixednames) # Add the name and value of the new variable to the expected ones. expected_names = sorted(expected_names + ["extra_var"])