diff --git a/python/tests/adapters/test_fiddy.py b/python/tests/adapters/test_fiddy.py index 4212a6de09..00769cc6dc 100644 --- a/python/tests/adapters/test_fiddy.py +++ b/python/tests/adapters/test_fiddy.py @@ -15,6 +15,7 @@ from fiddy import MethodId, Type, get_derivative from fiddy.derivative_check import NumpyIsCloseDerivativeCheck from fiddy.success import Consistency +from numpy.testing import assert_allclose from petab import v1 # Absolute and relative tolerances for finite difference gradient checks. @@ -85,13 +86,13 @@ def test_run_amici_simulation_to_functions(problem_generator): test_derivative = derivative.value # The test derivative is close to the expected derivative. - assert np.isclose( + assert_allclose( test_derivative, expected_derivative, rtol=1e-1, atol=1e-1, equal_nan=True, - ).all() + ) # Same as above assert. check = NumpyIsCloseDerivativeCheck( diff --git a/python/tests/test_bngl.py b/python/tests/test_bngl.py index 0c0a917b2f..6f1e9e5afb 100644 --- a/python/tests/test_bngl.py +++ b/python/tests/test_bngl.py @@ -11,6 +11,7 @@ from amici.importers.bngl import bngl2amici from amici.sim.sundials import run_simulation from amici.testing import TemporaryDirectoryWinSafe, skip_on_valgrind +from numpy.testing import assert_allclose from pysb.importers.bngl import model_from_bngl from pysb.simulator import ScipyOdeSimulator @@ -113,4 +114,4 @@ def test_compare_to_pysb_simulation(example): rdata = run_simulation(model_amici, solver) # check agreement of species simulation - assert np.isclose(rdata.x, pysb_simres.species, 1e-4, 1e-4).all() + assert_allclose(rdata.x, pysb_simres.species, 1e-4, 1e-4) diff --git a/python/tests/test_edata.py b/python/tests/test_edata.py index 689eb6281b..b12bd220f6 100644 --- a/python/tests/test_edata.py +++ b/python/tests/test_edata.py @@ -10,6 +10,7 @@ run_simulation, ) from amici.testing import skip_on_valgrind +from numpy.testing import assert_allclose @skip_on_valgrind @@ -51,5 +52,5 @@ def test_edata_sensi_unscaling(model_units_module): # noqa: F811 rdata1 = run_simulation(model, solver, edata1) # The initial state sensitivities are as specified. - assert np.isclose(rdata0.sx0.flatten(), sx0).all() - assert np.isclose(rdata1.sx0.flatten(), sx0).all() + assert_allclose(rdata0.sx0.flatten(), sx0) + assert_allclose(rdata1.sx0.flatten(), sx0) diff --git a/python/tests/test_pysb.py b/python/tests/test_pysb.py index 118103d81b..7c96a9351d 100644 --- a/python/tests/test_pysb.py +++ b/python/tests/test_pysb.py @@ -57,29 +57,32 @@ def test_compare_to_sbml_import( [rdata_sbml, rdata_pysb], [model_sbml, model_pysb], ["sbml", "pysb"] ): # check equilibrium fixed parameters - assert np.isclose( + assert_allclose( [sum(rdata["x_ss"][[1, 3]]), sum(rdata["x_ss"][[2, 4]])], edata.fixed_parameters_pre_equilibration, atol=1e-6, rtol=1e-6, - ).all(), f"{importer} preequilibration" + err_msg=f"{importer} preequilibration", + ) # check equilibrium initial parameters - assert np.isclose( + assert_allclose( sum(rdata["x_ss"][[0, 3, 4, 5]]), model.get_free_parameter_by_name("PROT_0"), atol=1e-6, rtol=1e-6, - ), f"{importer} preequilibration" + err_msg=f"{importer} preequilibration", + ) # check reinitialization with fixed parameter after # presimulation - assert np.isclose( + assert_allclose( [rdata["x0"][1], rdata["x0"][2]], edata.fixed_parameters, atol=1e-6, rtol=1e-6, - ).all(), f"{importer} presimulation" + err_msg=f"{importer} presimulation", + ) skip_attrs = [ "ptr", @@ -216,9 +219,7 @@ def test_compare_to_pysb_simulation(example): rdata = run_simulation(model_pysb, solver) # check agreement of species simulations - assert np.isclose( - rdata["x"], pysb_simres.species, 1e-4, 1e-4 - ).all() + assert_allclose(rdata["x"], pysb_simres.species, 1e-4, 1e-4) if example not in [ "fricker_2010_apoptosis",