From 8e3e34bbea99f36852c4f9a6eb586b51507af4fd Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Sat, 26 Feb 2022 09:13:59 +0000 Subject: [PATCH] tests: test for covariance of covobs added --- tests/covobs_test.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/covobs_test.py b/tests/covobs_test.py index 418cb83e..82cd4ae0 100644 --- a/tests/covobs_test.py +++ b/tests/covobs_test.py @@ -82,6 +82,19 @@ def test_covobs_init(): covobs = pe.cov_Obs([1, 2], np.array([[0.21, 0.2], [0.2, 0.21]]), 'test') +def test_covobs_covariance(): + a = pe.cov_Obs(2.47, 0.03 ** 2, "Cov_obs 1") + b = pe.cov_Obs(-4.3, 0.335 ** 2, "Cov_obs 2") + + x = [a + b, a - b] + [o.gamma_method() for o in x] + + covariance = pe.fits.covariance_matrix(x) + + assert covariance[0, 0] == covariance[1, 1] + assert covariance[0, 1] == a.dvalue ** 2 - b.dvalue ** 2 + + def test_covobs_exceptions(): with pytest.raises(Exception): covobs = pe.cov_Obs(0.1, [[0.1, 0.2], [0.1, 0.2]], 'test')