mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-16 07:10:24 +01:00
Merge branch 'develop' into documentation
This commit is contained in:
commit
d1447d057b
4 changed files with 25 additions and 3 deletions
2
.github/workflows/pytest.yml
vendored
2
.github/workflows/pytest.yml
vendored
|
@ -7,7 +7,7 @@ on:
|
|||
- develop
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: '0 4 * * *'
|
||||
- cron: '0 4 1 * *'
|
||||
|
||||
jobs:
|
||||
pytest:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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'])
|
||||
|
|
Loading…
Add table
Reference in a new issue