fix: covariance now works again for observables with covobs or non

overlapping idls
This commit is contained in:
Fabian Joswig 2022-04-28 15:12:08 +01:00
parent 9cfe56074d
commit 4be56514e5

View file

@ -1423,9 +1423,9 @@ def covariance(obs, visualize=False, correlation=False, smooth=None, **kwargs):
This construction ensures that the estimated covariance matrix is positive semi-definite (up to numerical rounding errors).
'''
mc_names = set([item for subnames in [o.mc_names for o in obs] for item in subnames])
names = set([item for subnames in [set(o.names) - set(o.cov_names) for o in obs] for item in subnames])
idl_d = {}
for name in mc_names:
for name in names:
idl_d[name] = _intersection_idx([o.idl.get(name) for o in obs if o.idl.get(name) is not None])
length = len(obs)
@ -1495,6 +1495,9 @@ def _covariance_element(obs1, obs2, idl_d):
if not hasattr(obs1, 'e_dvalue') or not hasattr(obs2, 'e_dvalue'):
raise Exception('The gamma method has to be applied to both Obs first.')
if obs1 is obs2:
dvalue = len(obs1.mc_names)
else:
dvalue = 0.0
for e_name in obs1.mc_names: