mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 19:43:41 +02:00
test: test for r_value propagation in fits added
This commit is contained in:
parent
28f1372cfd
commit
6028274342
1 changed files with 41 additions and 3 deletions
|
@ -208,3 +208,41 @@ def test_odr_derivatives():
|
|||
tfit = pe.fits.fit_general(x, y, func, base_step=0.1, step_ratio=1.1, num_steps=20)
|
||||
assert np.abs(np.max(np.array(list(fit1[1].deltas.values()))
|
||||
- np.array(list(tfit[1].deltas.values())))) < 10e-8
|
||||
|
||||
|
||||
def test_r_value_persistence():
|
||||
def f(a, x):
|
||||
return a[0] + a[1] * x
|
||||
|
||||
a = pe.pseudo_Obs(1.1, .1, 'a')
|
||||
assert np.isclose(a.value, a.r_values['a'])
|
||||
|
||||
a_2 = a ** 2
|
||||
assert np.isclose(a_2.value, a_2.r_values['a'])
|
||||
|
||||
b = pe.pseudo_Obs(2.1, .2, 'b')
|
||||
|
||||
y = [a, b]
|
||||
[o.gamma_method() for o in y]
|
||||
|
||||
fitp = pe.fits.least_squares([1, 2], y, f)
|
||||
|
||||
assert np.isclose(fitp[0].value, fitp[0].r_values['a'])
|
||||
assert np.isclose(fitp[0].value, fitp[0].r_values['b'])
|
||||
assert np.isclose(fitp[1].value, fitp[1].r_values['a'])
|
||||
assert np.isclose(fitp[1].value, fitp[1].r_values['b'])
|
||||
|
||||
fitp = pe.fits.total_least_squares(y, y, f)
|
||||
|
||||
assert np.isclose(fitp[0].value, fitp[0].r_values['a'])
|
||||
assert np.isclose(fitp[0].value, fitp[0].r_values['b'])
|
||||
assert np.isclose(fitp[1].value, fitp[1].r_values['a'])
|
||||
assert np.isclose(fitp[1].value, fitp[1].r_values['b'])
|
||||
|
||||
fitp = pe.fits.least_squares([1, 2], y, f, priors=y)
|
||||
|
||||
assert np.isclose(fitp[0].value, fitp[0].r_values['a'])
|
||||
assert np.isclose(fitp[0].value, fitp[0].r_values['b'])
|
||||
assert np.isclose(fitp[1].value, fitp[1].r_values['a'])
|
||||
assert np.isclose(fitp[1].value, fitp[1].r_values['b'])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue