mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
refactor!: if clause in Obs.__init__ eliminated, empty observables need
to be initialized with means=[] from now on.
This commit is contained in:
parent
42df254288
commit
498a251072
3 changed files with 38 additions and 39 deletions
|
@ -358,7 +358,7 @@ def _parse_json_dict(json_dict, verbose=True, full_output=False):
|
|||
ret = Obs([[ddi[0] + values[0] for ddi in di] for di in od['deltas']], od['names'], idl=od['idl'])
|
||||
ret.is_merged = od['is_merged']
|
||||
else:
|
||||
ret = Obs([], [])
|
||||
ret = Obs([], [], means=[])
|
||||
ret._value = values[0]
|
||||
for name in cd:
|
||||
co = cd[name][0]
|
||||
|
@ -383,7 +383,7 @@ def _parse_json_dict(json_dict, verbose=True, full_output=False):
|
|||
ret.append(Obs([list(di[:, i] + values[i]) for di in od['deltas']], od['names'], idl=od['idl']))
|
||||
ret[-1].is_merged = od['is_merged']
|
||||
else:
|
||||
ret.append(Obs([], []))
|
||||
ret.append(Obs([], [], means=[]))
|
||||
ret[-1]._value = values[i]
|
||||
print('Created Obs with means= ', values[i])
|
||||
for name in cd:
|
||||
|
@ -410,7 +410,7 @@ def _parse_json_dict(json_dict, verbose=True, full_output=False):
|
|||
ret.append(Obs([di[:, i] + values[i] for di in od['deltas']], od['names'], idl=od['idl']))
|
||||
ret[-1].is_merged = od['is_merged']
|
||||
else:
|
||||
ret.append(Obs([], []))
|
||||
ret.append(Obs([], [], means=[]))
|
||||
ret[-1]._value = values[i]
|
||||
for name in cd:
|
||||
co = cd[name][i]
|
||||
|
|
|
@ -94,7 +94,6 @@ class Obs:
|
|||
self.N = 0
|
||||
self.is_merged = {}
|
||||
self.idl = {}
|
||||
if len(samples):
|
||||
if idl is not None:
|
||||
for name, idx in sorted(zip(names, idl)):
|
||||
if isinstance(idx, range):
|
||||
|
@ -1522,7 +1521,7 @@ def cov_Obs(means, cov, name, grad=None):
|
|||
co : Covobs
|
||||
Covobs to be embedded into the Obs
|
||||
"""
|
||||
o = Obs([], [])
|
||||
o = Obs([], [], means=[])
|
||||
o._value = co.value
|
||||
o.names.append(co.name)
|
||||
o._covobs[co.name] = co
|
||||
|
|
|
@ -653,7 +653,7 @@ def test_covariance_symmetry():
|
|||
|
||||
def test_empty_obs():
|
||||
o = pe.Obs([np.random.rand(100)], ['test'])
|
||||
q = o + pe.Obs([], [])
|
||||
q = o + pe.Obs([], [], means=[])
|
||||
assert q == o
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue