mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
Ensure fixed dimensions of cov and grad in covobs. Allow for differences of O(1e-14) in two cov matrices, when combining observables
This commit is contained in:
parent
3324b0aa07
commit
3190140023
2 changed files with 4 additions and 1 deletions
|
@ -23,6 +23,7 @@ class Covobs:
|
|||
self.cov = np.array(cov)
|
||||
if self.cov.ndim == 0:
|
||||
self.N = 1
|
||||
self.cov = np.diag([self.cov])
|
||||
elif self.cov.ndim == 1:
|
||||
self.N = len(self.cov)
|
||||
self.cov = np.diag(self.cov)
|
||||
|
@ -48,6 +49,8 @@ class Covobs:
|
|||
self.grad[pos] = 1.
|
||||
else:
|
||||
self.grad = np.array(grad)
|
||||
if self.grad.ndim == 1:
|
||||
self.grad = np.reshape(self.grad, (self.N, 1))
|
||||
self.value = mean
|
||||
|
||||
def errsq(self):
|
||||
|
|
|
@ -1069,7 +1069,7 @@ def derived_observable(func, data, array_mode=False, **kwargs):
|
|||
for o in raveled_data:
|
||||
for name in o.cov_names:
|
||||
if name in allcov:
|
||||
if not np.array_equal(allcov[name], o.covobs[name].cov):
|
||||
if not np.allclose(allcov[name], o.covobs[name].cov, rtol=1e-14, atol=1e-14):
|
||||
raise Exception('Inconsistent covariance matrices for %s!' % (name))
|
||||
else:
|
||||
allcov[name] = o.covobs[name].cov
|
||||
|
|
Loading…
Add table
Reference in a new issue