mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
tests: tests for linalg and obs extended.
This commit is contained in:
parent
c9e1cd10af
commit
cd2f361a3e
2 changed files with 32 additions and 0 deletions
|
@ -314,6 +314,9 @@ def test_matrix_functions():
|
|||
# Check determinant
|
||||
assert pe.linalg.det(np.diag(np.diag(matrix))) == np.prod(np.diag(matrix))
|
||||
|
||||
with pytest.raises(Exception):
|
||||
pe.linalg.det(5)
|
||||
|
||||
pe.linalg.pinv(matrix[:,:3])
|
||||
|
||||
|
||||
|
@ -347,3 +350,10 @@ def test_complex_matrix_operations():
|
|||
diff = ta * tb - 1
|
||||
for (i, j), entry in np.ndenumerate(diff):
|
||||
assert entry.is_zero()
|
||||
|
||||
|
||||
def test_complex_matrix_real_entries():
|
||||
my_mat = get_complex_matrix(4)
|
||||
my_mat[0, 1] = 4
|
||||
my_mat[2, 0] = pe.Obs([np.random.normal(1.0, 0.1, 100)], ['t'])
|
||||
assert np.all((my_mat @ pe.linalg.inv(my_mat) - np.identity(4)) == 0)
|
||||
|
|
|
@ -51,6 +51,12 @@ def test_Obs_exceptions():
|
|||
my_obs.gamma_method()
|
||||
my_obs.details()
|
||||
|
||||
obs = pe.Obs([np.random.normal(1.0, 0.1, 100)], ['t'])
|
||||
one = obs / obs
|
||||
one.gamma_method()
|
||||
with pytest.raises(Exception):
|
||||
one.plot_piechart()
|
||||
|
||||
def test_dump():
|
||||
value = np.random.normal(5, 10)
|
||||
dvalue = np.abs(np.random.normal(0, 1))
|
||||
|
@ -86,6 +92,8 @@ def test_comparison():
|
|||
assert test_obs2 != value2
|
||||
assert test_obs1 != test_obs2
|
||||
assert test_obs2 != test_obs1
|
||||
assert +test_obs1 == test_obs1
|
||||
assert -test_obs1 == 0 - test_obs1
|
||||
|
||||
|
||||
def test_function_overloading():
|
||||
|
@ -367,6 +375,8 @@ def test_cobs():
|
|||
obs2 = pe.pseudo_Obs(-0.2, 0.03, 't')
|
||||
|
||||
my_cobs = pe.CObs(obs1, obs2)
|
||||
assert +my_cobs == my_cobs
|
||||
assert -my_cobs == 0 - my_cobs
|
||||
my_cobs == my_cobs
|
||||
str(my_cobs)
|
||||
repr(my_cobs)
|
||||
|
@ -758,3 +768,15 @@ def test_merge_idx():
|
|||
assert(new_idx[-1] > new_idx[0])
|
||||
for i in range(1, len(new_idx)):
|
||||
assert(new_idx[i - 1] < new_idx[i])
|
||||
|
||||
def test_cobs_array():
|
||||
cobs = pe.Obs([np.random.normal(1.0, 0.1, 100)], ['t']) * (1 + 2j)
|
||||
np.identity(4) + cobs
|
||||
cobs + np.identity(4)
|
||||
np.identity(4) - cobs
|
||||
cobs - np.identity(4)
|
||||
np.identity(4) * cobs
|
||||
cobs * np.identity(4)
|
||||
np.identity(4) / cobs
|
||||
cobs / np.ones((4, 4))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue