Merge branch 'develop' into feat/meas_class

This commit is contained in:
Fabian Joswig 2025-01-06 11:13:55 +01:00 committed by GitHub
commit 8c7cd5a74b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 218 additions and 165 deletions

View file

@ -61,9 +61,9 @@ def test_Obs_exceptions():
my_obs.plot_rep_dist()
with pytest.raises(Exception):
my_obs.plot_piechart()
with pytest.raises(Exception):
with pytest.raises(TypeError):
my_obs.gamma_method(S='2.3')
with pytest.raises(Exception):
with pytest.raises(ValueError):
my_obs.gamma_method(tau_exp=2.3)
my_obs.gamma_method()
my_obs.details()
@ -199,7 +199,7 @@ def test_gamma_method_no_windowing():
assert np.isclose(np.sqrt(np.var(obs.deltas['ens'], ddof=1) / obs.shape['ens']), obs.dvalue)
obs.gamma_method(S=1.1)
assert obs.e_tauint['ens'] > 0.5
with pytest.raises(Exception):
with pytest.raises(ValueError):
obs.gamma_method(S=-0.2)
@ -461,6 +461,18 @@ def test_cobs_overloading():
obs / cobs
def test_pow():
data = [1, 2.341, pe.pseudo_Obs(4.8, 0.48, "test_obs"), pe.cov_Obs(1.1, 0.3 ** 2, "test_cov_obs")]
for d in data:
assert d * d == d ** 2
assert d * d * d == d ** 3
for d2 in data:
assert np.log(d ** d2) == d2 * np.log(d)
assert (d ** d2) ** (1 / d2) == d
def test_reweighting():
my_obs = pe.Obs([np.random.rand(1000)], ['t'])
assert not my_obs.reweighted
@ -478,12 +490,12 @@ def test_reweighting():
r_obs2 = r_obs[0] * my_obs
assert r_obs2.reweighted
my_covobs = pe.cov_Obs(1.0, 0.003, 'cov')
with pytest.raises(Exception):
with pytest.raises(ValueError):
pe.reweight(my_obs, [my_covobs])
my_obs2 = pe.Obs([np.random.rand(1000)], ['t2'])
with pytest.raises(Exception):
with pytest.raises(ValueError):
pe.reweight(my_obs, [my_obs + my_obs2])
with pytest.raises(Exception):
with pytest.raises(ValueError):
pe.reweight(my_irregular_obs, [my_obs])
@ -493,10 +505,10 @@ def test_merge_obs():
merged = pe.merge_obs([my_obs1, my_obs2])
diff = merged - my_obs2 - my_obs1
assert diff == -(my_obs1.value + my_obs2.value) / 2
with pytest.raises(Exception):
with pytest.raises(ValueError):
pe.merge_obs([my_obs1, my_obs1])
my_covobs = pe.cov_Obs(1.0, 0.003, 'cov')
with pytest.raises(Exception):
with pytest.raises(ValueError):
pe.merge_obs([my_obs1, my_covobs])
@ -519,11 +531,11 @@ def test_correlate():
assert corr1 == corr2
my_obs3 = pe.Obs([np.random.rand(100)], ['t'], idl=[range(2, 102)])
with pytest.raises(Exception):
with pytest.raises(ValueError):
pe.correlate(my_obs1, my_obs3)
my_obs4 = pe.Obs([np.random.rand(99)], ['t'])
with pytest.raises(Exception):
with pytest.raises(ValueError):
pe.correlate(my_obs1, my_obs4)
my_obs5 = pe.Obs([np.random.rand(100)], ['t'], idl=[range(5, 505, 5)])
@ -532,10 +544,10 @@ def test_correlate():
assert my_obs5.idl == corr3.idl
my_new_obs = pe.Obs([np.random.rand(100)], ['q3'])
with pytest.raises(Exception):
with pytest.raises(ValueError):
pe.correlate(my_obs1, my_new_obs)
my_covobs = pe.cov_Obs(1.0, 0.003, 'cov')
with pytest.raises(Exception):
with pytest.raises(ValueError):
pe.correlate(my_covobs, my_covobs)
r_obs = pe.reweight(my_obs1, [my_obs1])[0]
with pytest.warns(RuntimeWarning):
@ -762,7 +774,7 @@ def test_gamma_method_irregular():
my_obs.gm()
idl += [range(1, 400, 4)]
my_obs = pe.Obs([dat for i in range(len(idl))], ['%s|%d' % ('A', i) for i in range(len(idl))], idl=idl)
with pytest.raises(Exception):
with pytest.raises(ValueError):
my_obs.gm()
# check cases where tau is large compared to the chain length
@ -1110,7 +1122,7 @@ def test_jackknife():
assert np.allclose(tmp_jacks, my_obs.export_jackknife())
my_new_obs = my_obs + pe.Obs([full_data], ['test2'])
with pytest.raises(Exception):
with pytest.raises(ValueError):
my_new_obs.export_jackknife()