From f5c9a30266ad6c2a5d835aab00e0025194cca227 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Fri, 7 Oct 2022 18:02:27 +0100 Subject: [PATCH] tests: tests for num_grad version of prior fits added. --- tests/fits_test.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/fits_test.py b/tests/fits_test.py index 4018abb8..374f590a 100644 --- a/tests/fits_test.py +++ b/tests/fits_test.py @@ -97,6 +97,35 @@ def test_least_squares_num_grad(): assert(num[1] == auto[1]) +def test_prior_fit_num_grad(): + x = [] + y = [] + for i in range(2, 5): + x.append(i * 0.01) + y.append(pe.pseudo_Obs(i * 0.01, 0.0001, "ens")) + + num = pe.fits.least_squares(x, y, lambda a, x: np.exp(a[0] * x) + a[1], num_grad=True, priors=y[:2]) + auto = pe.fits.least_squares(x, y, lambda a, x: anp.exp(a[0] * x) + a[1], num_grad=False, piors=y[:2]) + + +def test_least_squares_num_grad(): + x = [] + y = [] + for i in range(2, 5): + x.append(i * 0.01) + y.append(pe.pseudo_Obs(i * 0.01, 0.0001, "ens")) + + num = pe.fits.least_squares(x, y, lambda a, x: np.exp(a[0] * x) + a[1], num_grad=True) + auto = pe.fits.least_squares(x, y, lambda a, x: anp.exp(a[0] * x) + a[1], num_grad=False) + + assert(num[0] == auto[0]) + assert(num[1] == auto[1]) + + + assert(num[0] == auto[0]) + assert(num[1] == auto[1]) + + def test_total_least_squares_num_grad(): x = [] y = []