Merge pull request #61 from fjosw/fix/json_corr_covobs

fix: Bug in export of derivative of correlator containing covobs fixed, test added.
This commit is contained in:
Fabian Joswig 2022-02-09 14:27:04 +00:00 committed by GitHub
commit 41deec6d7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -171,6 +171,9 @@ def create_json_string(ol, description='', indent=1):
names.append(key)
idl.append(value)
my_obs = Obs(samples, names, idl)
my_obs._covobs = obs._covobs
for name in obs._covobs:
my_obs.names.append(name)
my_obs.reweighted = obs.reweighted
my_obs.is_merged = obs.is_merged
return my_obs

View file

@ -242,3 +242,12 @@ def test_json_dict_io():
jsonio.dump_dict_to_json(od, fname, description=desc)
os.remove(fname + '.json.gz')
def test_renorm_deriv_of_corr(tmp_path):
c = pe.Corr([pe.pseudo_Obs(i, .1, 'test') for i in range(10)])
c *= pe.cov_Obs(1., .1, '#ren')
c = c.deriv()
pe.input.json.dump_to_json(c, (tmp_path / 'test').as_posix())
recover = pe.input.json.load_json((tmp_path / 'test').as_posix())
assert np.all([o == 0 for o in (c - recover)[1:-1]])