From 33b5d701147304b6aaf796da29c31ff59db4f6a0 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Wed, 1 Dec 2021 14:58:00 +0000 Subject: [PATCH 1/2] fix: bug in Obs.is_zero in connection with covobs fixed --- pyerrors/obs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyerrors/obs.py b/pyerrors/obs.py index e925c51b..35c97454 100644 --- a/pyerrors/obs.py +++ b/pyerrors/obs.py @@ -459,7 +459,7 @@ class Obs: atol : float Absolute tolerance (for details see numpy documentation). """ - return (np.isclose(0.0, self.value, rtol, atol) and all(np.allclose(0.0, delta, rtol, atol) for delta in self.deltas.values()) and all(np.allclose(0.0, delta.grad, rtol, atol) for delta in self.covobs.values())) + return np.isclose(0.0, self.value, rtol, atol) and all(np.allclose(0.0, delta, rtol, atol) for delta in self.deltas.values()) and all(np.allclose(0.0, delta.errsq(), rtol, atol) for delta in self.covobs.values()) def plot_tauint(self, save=None): """Plot integrated autocorrelation time for each ensemble. From e1ab5c68817fa6028d3b3e421d98edf412c58aa3 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Wed, 1 Dec 2021 14:59:29 +0000 Subject: [PATCH 2/2] test: test for covobs overloading added --- tests/obs_test.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/obs_test.py b/tests/obs_test.py index 8af54d56..d93fbe5f 100644 --- a/tests/obs_test.py +++ b/tests/obs_test.py @@ -581,3 +581,9 @@ def test_covobs(): do = cl[0] * cl[1] assert(np.array_equal(do.covobs['rAP'].grad, np.transpose([pi[1], pi[0]]).reshape(2, 1))) + + +def test_covobs_overloading(): + covobs = pe.cov_Obs([0.5, 0.5], np.array([[0.02, 0.02], [0.02, 0.02]]), 'Zfactor') + assert (covobs[0] / covobs[1]) == 1 + assert (covobs[0] - covobs[1]) == 0