fix for lists and arrays of noise
@@ -196,10 +196,14 @@ def prec_from_residuals(residuals, dof=None, method='shrinkage_diag'):
"""
cov = cov_from_residuals(residuals=residuals, dof=dof, method=method)
- if not isinstance(cov, np.ndarray) or len(cov.shape) > 2:
+ if not isinstance(cov, np.ndarray):
prec = [None] * len(cov)
for i in range(len(cov)):
prec[i] = np.linalg.inv(cov[i])
+ elif len(cov.shape) > 2:
+ prec = np.zeros(cov.shape)
+ for i in range(len(cov)):
+ prec[i] = np.linalg.inv(cov[i])
else:
prec = np.linalg.inv(cov)
return prec
@@ -272,8 +276,12 @@ def prec_from_measurements(dataset, obs_desc, dof=None, method='shrinkage_diag')
"""
cov = cov_from_measurements(dataset, obs_desc, dof=dof, method=method)
+ if not isinstance(cov, np.ndarray):
+ prec = [None] * len(cov)
+ for i in range(len(cov)):
+ prec[i] = np.linalg.inv(cov[i])
+ elif len(cov.shape) > 2:
prec = np.zeros(cov.shape)
- if not isinstance(cov, np.ndarray) or len(cov.shape) > 2:
for i in range(len(cov)):
prec[i] = np.linalg.inv(cov[i])
else:
