diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index db0b8de1..b9d60c7a 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -7,7 +7,7 @@ on: - develop pull_request: schedule: - - cron: '0 4 * * *' + - cron: '0 4 1 * *' jobs: pytest: diff --git a/pyerrors/obs.py b/pyerrors/obs.py index c24da74a..168f7292 100644 --- a/pyerrors/obs.py +++ b/pyerrors/obs.py @@ -125,8 +125,6 @@ class Obs: for name, sample, mean in sorted(zip(names, samples, means)): self.shape[name] = len(self.idl[name]) self.N += self.shape[name] - if len(sample) != self.shape[name]: - raise Exception('Incompatible samples and idx for %s: %d vs. %d' % (name, len(sample), self.shape[name])) self.r_values[name] = mean self.deltas[name] = sample else: diff --git a/tests/correlators_test.py b/tests/correlators_test.py index f27bba54..6c3418f8 100644 --- a/tests/correlators_test.py +++ b/tests/correlators_test.py @@ -91,6 +91,14 @@ def test_fit_correlator(): assert fit_res[1] == my_corr[1] - my_corr[0] +def test_plateau(): + my_corr = pe.correlators.Corr([pe.pseudo_Obs(1.01324, 0.05, 't'), pe.pseudo_Obs(1.042345, 0.008, 't')]) + + my_corr.plateau([0, 1], method="fit") + my_corr.plateau([0, 1], method="mean") + with pytest.raises(Exception): + my_corr.plateau() + def test_utility(): corr_content = [] for t in range(8): diff --git a/tests/obs_test.py b/tests/obs_test.py index f5d04832..8fbfa43d 100644 --- a/tests/obs_test.py +++ b/tests/obs_test.py @@ -22,6 +22,12 @@ def test_Obs_exceptions(): pe.Obs([np.random.rand(10)], [1]) with pytest.raises(Exception): pe.Obs([np.random.rand(4)], ['name']) + with pytest.raises(Exception): + pe.Obs([np.random.rand(5)], ['1'], idl=[[5, 3, 2 ,4 ,1]]) + with pytest.raises(Exception): + pe.Obs([np.random.rand(5)], ['1'], idl=['t']) + with pytest.raises(Exception): + pe.Obs([np.random.rand(5)], ['1'], idl=[range(1, 8)]) my_obs = pe.Obs([np.random.rand(6)], ['name']) my_obs._value = 0.0 @@ -346,6 +352,7 @@ def test_overloaded_functions(): def test_utils(): + zero_pseudo_obs = pe.pseudo_Obs(1.0, 0.0, 'null') my_obs = pe.pseudo_Obs(1.0, 0.5, 't|r01') my_obs += pe.pseudo_Obs(1.0, 0.5, 't|r02') str(my_obs) @@ -412,6 +419,15 @@ def test_reweighting(): r_obs2 = r_obs[0] * my_obs assert r_obs2.reweighted + my_irregular_obs = pe.Obs([np.random.rand(500)], ['t'], idl=[range(1, 1001, 2)]) + assert not my_irregular_obs.reweighted + r_obs = pe.reweight(my_obs, [my_irregular_obs], all_configs=True) + r_obs = pe.reweight(my_obs, [my_irregular_obs], all_configs=False) + r_obs = pe.reweight(my_obs, [my_obs]) + assert r_obs[0].reweighted + r_obs2 = r_obs[0] * my_obs + assert r_obs2.reweighted + def test_merge_obs(): my_obs1 = pe.Obs([np.random.rand(100)], ['t'])