From 1d774a7761338dc6e0c0c91b8e6a4bfbad55bfab Mon Sep 17 00:00:00 2001 From: JoepVanlier Date: Mon, 14 Aug 2023 17:37:45 +0200 Subject: [PATCH] fdfit: update tests It is no longer needed to explicitly provide finite inversion limits. We will only use the interpolation method in the range where our data lives, and outside we always use explicit optimization. --- lumicks/pylake/fitting/tests/test_fd_models.py | 2 +- .../pylake/fitting/tests/test_model_composition.py | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/lumicks/pylake/fitting/tests/test_fd_models.py b/lumicks/pylake/fitting/tests/test_fd_models.py index b18cb1a0e..3eb730340 100644 --- a/lumicks/pylake/fitting/tests/test_fd_models.py +++ b/lumicks/pylake/fitting/tests/test_fd_models.py @@ -59,7 +59,7 @@ def test_models(): # Check the tWLC and inverted tWLC model params = [5, 5, 5, 3, 2, 1, 6, 4.11] assert twlc_distance("tWLC").verify_jacobian(independent, params) - assert twlc_force("itWLC").verify_jacobian(independent, params) + assert twlc_force("itWLC").verify_jacobian(independent, params, rtol=1e-4) # Check whether the twistable wlc model manipulates the data order np.testing.assert_allclose( diff --git a/lumicks/pylake/fitting/tests/test_model_composition.py b/lumicks/pylake/fitting/tests/test_model_composition.py index d0add8b06..074840925 100644 --- a/lumicks/pylake/fitting/tests/test_model_composition.py +++ b/lumicks/pylake/fitting/tests/test_model_composition.py @@ -134,21 +134,14 @@ def test_subtract_independent_offset_unit(model, param, unit): assert model.defaults[param].unit == unit -def test_interpolation_inversion(): - m = ewlc_odijk_distance("Nucleosome").invert(independent_max=120.0, interpolate=True) +@pytest.mark.parametrize("method", ["exact", "interp_lsq", "interp_root"]) +def test_interpolation_inversion(method): + m = ewlc_odijk_distance("Nucleosome").invert(independent_max=120.0, method=method) parvec = [5.77336105517341, 7.014180463612673, 1500.0000064812095, 4.11] result = np.array([0.17843862, 0.18101283, 0.18364313, 0.18633117, 0.18907864]) np.testing.assert_allclose(m._raw_call(np.arange(10, 250, 50) / 1000, parvec), result) -@pytest.mark.parametrize("param", [{"independent_max": np.inf}, {"independent_min": -np.inf}]) -def test_interpolation_invalid_range(param): - with pytest.raises( - ValueError, match="Inversion limits have to be finite when using interpolation method" - ): - ewlc_odijk_distance("Nucleosome").invert(**param, interpolate=True) - - def test_uuids(): m1, m2 = (Model(name, lambda x: x, dependent="x") for name in ("M1", "M2")) m3 = CompositeModel(m1, m2)