mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
Hidden _set_cov and _set_grad, modified test for equality of covs
This commit is contained in:
parent
7c5465d828
commit
a5cf0270d3
2 changed files with 5 additions and 5 deletions
|
@ -20,7 +20,7 @@ class Covobs:
|
|||
grad : list or array
|
||||
Gradient of the Covobs wrt. the means belonging to cov.
|
||||
"""
|
||||
self.set_cov(cov)
|
||||
self._set_cov(cov)
|
||||
if '|' in name:
|
||||
raise Exception("Covobs name must not contain replica separator '|'.")
|
||||
self.name = name
|
||||
|
@ -36,7 +36,7 @@ class Covobs:
|
|||
self._grad = np.zeros((self.N, 1))
|
||||
self._grad[pos] = 1.
|
||||
else:
|
||||
self.set_grad(grad)
|
||||
self._set_grad(grad)
|
||||
self.value = mean
|
||||
|
||||
def errsq(self):
|
||||
|
@ -44,7 +44,7 @@ class Covobs:
|
|||
"""
|
||||
return float(np.dot(np.transpose(self.grad), np.dot(self.cov, self.grad)))
|
||||
|
||||
def set_cov(self, cov):
|
||||
def _set_cov(self, cov):
|
||||
self._cov = np.array(cov)
|
||||
if self._cov.ndim == 0:
|
||||
self.N = 1
|
||||
|
@ -59,7 +59,7 @@ class Covobs:
|
|||
else:
|
||||
raise Exception('Covariance matrix has to be a 2 dimensional square matrix!')
|
||||
|
||||
def set_grad(self, grad):
|
||||
def _set_grad(self, grad):
|
||||
self._grad = np.array(grad)
|
||||
if self._grad.ndim in [0, 1]:
|
||||
self._grad = np.reshape(self._grad, (self.N, 1))
|
||||
|
|
|
@ -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.allclose(allcov[name], o.covobs[name].cov, rtol=1e-14, atol=1e-14):
|
||||
if not np.allclose(allcov[name], o.covobs[name].cov):
|
||||
raise Exception('Inconsistent covariance matrices for %s!' % (name))
|
||||
else:
|
||||
allcov[name] = o.covobs[name].cov
|
||||
|
|
Loading…
Add table
Reference in a new issue