mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-15 03:53:41 +02:00
Merge branch 'develop' into documentation
This commit is contained in:
commit
431ac7c30d
5 changed files with 85 additions and 19 deletions
|
@ -32,3 +32,32 @@ def test_grid_dirac():
|
|||
pe.dirac.Grid_gamma(gamma)
|
||||
with pytest.raises(Exception):
|
||||
pe.dirac.Grid_gamma('Not a gamma matrix')
|
||||
|
||||
|
||||
def test_epsilon_tensor():
|
||||
check = {(1, 2, 3) : 1.0,
|
||||
(3, 1, 2) : 1.0,
|
||||
(2, 3, 1) : 1.0,
|
||||
(1, 1, 1) : 0.0,
|
||||
(3, 2, 1) : -1.0,
|
||||
(1, 3, 2) : -1.0,
|
||||
(1, 1, 3) : 0.0}
|
||||
for key, value in check.items():
|
||||
assert pe.dirac.epsilon_tensor(*key) == value
|
||||
with pytest.raises(Exception):
|
||||
pe.dirac.epsilon_tensor(0, 1, 3)
|
||||
|
||||
|
||||
def test_epsilon_tensor_rank4():
|
||||
check = {(1, 4, 3, 2) : -1.0,
|
||||
(1, 2, 3, 4) : 1.0,
|
||||
(2, 1, 3, 4) : -1.0,
|
||||
(4, 3, 2, 1) : 1.0,
|
||||
(3, 2, 4, 3) : 0.0,
|
||||
(0, 1, 2, 3) : 1.0,
|
||||
(1, 1, 1, 1) : 0.0,
|
||||
(1, 2, 3, 1) : 0.0}
|
||||
for key, value in check.items():
|
||||
assert pe.dirac.epsilon_tensor_rank4(*key) == value
|
||||
with pytest.raises(Exception):
|
||||
pe.dirac.epsilon_tensor_rank4(0, 1, 3, 4)
|
||||
|
|
|
@ -57,6 +57,7 @@ def test_dump():
|
|||
value = np.random.normal(5, 10)
|
||||
dvalue = np.abs(np.random.normal(0, 1))
|
||||
test_obs = pe.pseudo_Obs(value, dvalue, 't')
|
||||
test_obs.dump('test_dump', path=".")
|
||||
test_obs.dump('test_dump')
|
||||
new_obs = pe.load_object('test_dump.p')
|
||||
os.remove('test_dump.p')
|
||||
|
@ -105,6 +106,12 @@ def test_function_overloading():
|
|||
assert np.sqrt(b ** 2) == b
|
||||
assert np.sqrt(b) ** 2 == b
|
||||
|
||||
np.arcsin(1 / b)
|
||||
np.arccos(1 / b)
|
||||
np.arctan(1 / b)
|
||||
np.arctanh(1 / b)
|
||||
np.sinc(1 / b)
|
||||
|
||||
|
||||
def test_overloading_vectorization():
|
||||
a = np.random.randint(1, 100, 10)
|
||||
|
@ -428,6 +435,14 @@ def test_reweighting():
|
|||
assert r_obs[0].reweighted
|
||||
r_obs2 = r_obs[0] * my_obs
|
||||
assert r_obs2.reweighted
|
||||
my_covobs = pe.cov_Obs(1.0, 0.003, 'cov')
|
||||
with pytest.raises(Exception):
|
||||
pe.reweight(my_obs, [my_covobs])
|
||||
my_obs2 = pe.Obs([np.random.rand(1000)], ['t2'])
|
||||
with pytest.raises(Exception):
|
||||
pe.reweight(my_obs, [my_obs + my_obs2])
|
||||
with pytest.raises(Exception):
|
||||
pe.reweight(my_irregular_obs, [my_obs])
|
||||
|
||||
|
||||
def test_merge_obs():
|
||||
|
@ -436,6 +451,12 @@ def test_merge_obs():
|
|||
merged = pe.merge_obs([my_obs1, my_obs2])
|
||||
diff = merged - my_obs2 - my_obs1
|
||||
assert diff == -(my_obs1.value + my_obs2.value) / 2
|
||||
with pytest.raises(Exception):
|
||||
pe.merge_obs([my_obs1, my_obs1])
|
||||
my_covobs = pe.cov_Obs(1.0, 0.003, 'cov')
|
||||
with pytest.raises(Exception):
|
||||
pe.merge_obs([my_obs1, my_covobs])
|
||||
|
||||
|
||||
|
||||
def test_merge_obs_r_values():
|
||||
|
@ -468,6 +489,17 @@ def test_correlate():
|
|||
corr3 = pe.correlate(my_obs5, my_obs6)
|
||||
assert my_obs5.idl == corr3.idl
|
||||
|
||||
my_new_obs = pe.Obs([np.random.rand(100)], ['q3'])
|
||||
with pytest.raises(Exception):
|
||||
pe.correlate(my_obs1, my_new_obs)
|
||||
my_covobs = pe.cov_Obs(1.0, 0.003, 'cov')
|
||||
with pytest.raises(Exception):
|
||||
pe.correlate(my_covobs, my_covobs)
|
||||
r_obs = pe.reweight(my_obs1, [my_obs1])[0]
|
||||
with pytest.warns(RuntimeWarning):
|
||||
pe.correlate(r_obs, r_obs)
|
||||
|
||||
|
||||
|
||||
def test_irregular_error_propagation():
|
||||
obs_list = [pe.Obs([np.random.rand(100)], ['t']),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue