mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
fix: array mode now works for elements with different covobs
This commit is contained in:
parent
674a1ea6f6
commit
b0610544a8
2 changed files with 9 additions and 2 deletions
|
@ -1148,6 +1148,13 @@ def derived_observable(func, data, array_mode=False, **kwargs):
|
|||
|
||||
# TODO: array mode does not work when matrices are defined on differenet ensembles
|
||||
if array_mode is True:
|
||||
|
||||
class Zero_grad():
|
||||
def __init__(self):
|
||||
self.grad = 0
|
||||
|
||||
zero_grad = Zero_grad()
|
||||
|
||||
d_extracted = {}
|
||||
g_extracted = {}
|
||||
for name in new_sample_names:
|
||||
|
@ -1158,7 +1165,7 @@ def derived_observable(func, data, array_mode=False, **kwargs):
|
|||
for name in new_cov_names:
|
||||
g_extracted[name] = []
|
||||
for i_dat, dat in enumerate(data):
|
||||
g_extracted[name].append(np.array([o.covobs[name].grad for o in dat.reshape(np.prod(dat.shape))]).reshape(dat.shape + (1, )))
|
||||
g_extracted[name].append(np.array([o.covobs.get(name, zero_grad).grad for o in dat.reshape(np.prod(dat.shape))]).reshape(dat.shape + (1, )))
|
||||
|
||||
for i_val, new_val in np.ndenumerate(new_values):
|
||||
new_deltas = {}
|
||||
|
|
|
@ -189,7 +189,7 @@ def test_matmul_irregular_histories():
|
|||
standard_array = []
|
||||
for i in range(dim ** 2):
|
||||
standard_array.append(pe.Obs([np.random.normal(1.1, 0.2, length)], ['ens1']))
|
||||
standard_matrix = np.array(standard_array).reshape((dim, dim)) # * pe.pseudo_Obs(0.1, 0.002, 'qr')
|
||||
standard_matrix = np.array(standard_array).reshape((dim, dim)) * pe.cov_Obs(1.0, 0.002, 'cov') # * pe.pseudo_Obs(0.1, 0.002, 'qr')
|
||||
|
||||
for idl in [range(1, 501, 2), range(250, 273), [2, 8, 19, 20, 78]]:
|
||||
irregular_array = []
|
||||
|
|
Loading…
Add table
Reference in a new issue