feat: Check for symmetry and positive-semidefiniteness of covariance matrices in the initialization of covobs

This commit is contained in:
Simon Kuberski 2022-02-25 17:39:49 +01:00
parent 24a0df6a2a
commit 751d28711f
2 changed files with 35 additions and 3 deletions

View file

@ -78,9 +78,8 @@ def test_covobs_init():
covobs = pe.cov_Obs(0.5, 0.002, 'test')
covobs = pe.cov_Obs([1, 2], [0.1, 0.2], 'test')
covobs = pe.cov_Obs([1, 2], np.array([0.1, 0.2]), 'test')
covobs = pe.cov_Obs([1, 2], [[0.1, 0.2], [0.1, 0.2]], 'test')
covobs = pe.cov_Obs([1, 2], np.array([[0.1, 0.2], [0.1, 0.2]]), 'test')
covobs = pe.cov_Obs([1, 2], [[0.21, 0.2], [0.2, 0.21]], 'test')
covobs = pe.cov_Obs([1, 2], np.array([[0.21, 0.2], [0.2, 0.21]]), 'test')
def test_covobs_exceptions():
@ -92,3 +91,7 @@ def test_covobs_exceptions():
covobs = pe.cov_Obs([0.5, 0.1], np.array([[2, 1, 3], [1, 2, 3]]), 'test')
with pytest.raises(Exception):
covobs = pe.cov_Obs([0.5, 0.1], np.random.random((2, 2, 2)), 'test')
with pytest.raises(Exception):
covobs = pe.cov_Obs([1.5, 0.1], [[1., .2,], [.3, .5]] , 'test')
with pytest.raises(Exception):
covobs = pe.cov_Obs([1.5, 0.1], [[8, 4,], [4, -2]] , 'test')