mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 19:43:41 +02:00
rtruediv implemented for CObs, tests extended
This commit is contained in:
parent
c634d183a1
commit
325293f2b4
3 changed files with 27 additions and 11 deletions
|
@ -54,8 +54,12 @@ def test_function_overloading():
|
|||
t1 = f([a, b])
|
||||
t2 = pe.derived_observable(f, [a, b])
|
||||
c = t2 - t1
|
||||
assert c.value == 0.0, str(i)
|
||||
assert np.all(np.abs(c.deltas['e1']) < 1e-14), str(i)
|
||||
assert c.is_zero()
|
||||
|
||||
assert np.log(np.exp(b)) == b
|
||||
assert np.exp(np.log(b)) == b
|
||||
assert np.sqrt(b ** 2) == b
|
||||
assert np.sqrt(b) ** 2 == b
|
||||
|
||||
|
||||
def test_overloading_vectorization():
|
||||
|
@ -197,6 +201,7 @@ def test_overloaded_functions():
|
|||
assert np.abs((ad_obs.value - item(val)) / ad_obs.value) < 1e-10, item.__name__
|
||||
assert np.abs(ad_obs.dvalue - dval * np.abs(deriv[i](val))) < 1e-6, item.__name__
|
||||
|
||||
|
||||
def test_utils():
|
||||
my_obs = pe.pseudo_Obs(1.0, 0.5, 't')
|
||||
my_obs.print(0)
|
||||
|
@ -211,6 +216,7 @@ def test_utils():
|
|||
assert my_obs > (my_obs - 1)
|
||||
assert my_obs < (my_obs + 1)
|
||||
|
||||
|
||||
def test_cobs():
|
||||
obs1 = pe.pseudo_Obs(1.0, 0.1, 't')
|
||||
obs2 = pe.pseudo_Obs(-0.2, 0.03, 't')
|
||||
|
@ -227,22 +233,22 @@ def test_cobs():
|
|||
|
||||
fs = [[lambda x: x[0] + x[1], lambda x: x[1] + x[0]],
|
||||
[lambda x: x[0] * x[1], lambda x: x[1] * x[0]]]
|
||||
for other in [1, 1.1, (1.1-0.2j), pe.CObs(obs1), pe.CObs(obs1, obs2)]:
|
||||
for other in [3, 1.1, (1.1 - 0.2j), (2.3 + 0j), (0.0 + 7.7j), pe.CObs(obs1), pe.CObs(obs1, obs2)]:
|
||||
for funcs in fs:
|
||||
ta = funcs[0]([my_cobs, other])
|
||||
tb = funcs[1]([my_cobs, other])
|
||||
diff = ta - tb
|
||||
assert np.isclose(0.0, float(diff.real))
|
||||
assert np.isclose(0.0, float(diff.imag))
|
||||
assert np.allclose(0.0, diff.real.deltas['t'])
|
||||
assert np.allclose(0.0, diff.imag.deltas['t'])
|
||||
assert diff.is_zero()
|
||||
|
||||
ta = my_cobs - other
|
||||
tb = other - my_cobs
|
||||
diff = ta + tb
|
||||
assert np.isclose(0.0, float(diff.real))
|
||||
assert np.isclose(0.0, float(diff.imag))
|
||||
assert np.allclose(0.0, diff.real.deltas['t'])
|
||||
assert np.allclose(0.0, diff.imag.deltas['t'])
|
||||
assert diff.is_zero()
|
||||
|
||||
ta = my_cobs / other
|
||||
tb = other / my_cobs
|
||||
diff = ta * tb - 1
|
||||
assert diff.is_zero()
|
||||
|
||||
assert (my_cobs / other * other - my_cobs).is_zero()
|
||||
assert (other / my_cobs * my_cobs - other).is_zero()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue