Merge branch 'develop' into documentation

This commit is contained in:
fjosw 2021-12-07 17:34:39 +00:00
commit 35c1260d15
5 changed files with 71 additions and 5 deletions

View file

@ -20,14 +20,15 @@ Please add docstrings to any new function, class or method you implement. The do
### Tests
When implementing a new feature or fixing a bug please add meaningful tests to the files in the `tests` directory which cover the new code.
### Continous integration
For all pull requests tests are executed for the most recent python releases via
```
pytest --cov=pyerrors -vv
```
requiring `pytest`, `pytest-cov` and `pytest-benchmark`
and the linter `flake8` is executed with the command
requiring `pytest`, `pytest-cov` and `pytest-benchmark`. To get a coverage report in html run
```
pytest --cov=pyerrors --cov-report html
```
The linter `flake8` is executed with the command
```
flake8 --ignore=E501,E722 --exclude=__init__.py pyerrors
```

View file

@ -402,7 +402,7 @@ def _prior_fit(x, y, func, priors, silent=False, **kwargs):
if not silent:
print('chisquare/d.o.f.:', output.chisquare_by_dof)
if not m.get_fmin().is_valid:
if not m.fmin.is_valid:
raise Exception('The minimization procedure did not converge.')
hess_inv = np.linalg.pinv(jacobian(jacobian(chisqfunc))(params))

View file

@ -62,6 +62,9 @@ def test_covobs_name_collision():
my_obs = pe.pseudo_Obs(2.3, 0.2, 'test')
with pytest.raises(Exception):
summed_obs = my_obs + covobs
covobs2 = pe.cov_Obs(0.3, 0.001, 'test')
with pytest.raises(Exception):
summed_obs = covobs + covobs2
def test_covobs_replica_separator():

View file

@ -10,3 +10,25 @@ def test_gamma_matrices():
assert np.allclose(matrix @ matrix, np.identity(4))
assert np.allclose(matrix, matrix.T.conj())
assert np.allclose(pe.dirac.gamma5, pe.dirac.gamma[0] @ pe.dirac.gamma[1] @ pe.dirac.gamma[2] @ pe.dirac.gamma[3])
def test_grid_dirac():
for gamma in ['Identity',
'Gamma5',
'GammaX',
'GammaY',
'GammaZ',
'GammaT',
'GammaXGamma5',
'GammaYGamma5',
'GammaZGamma5',
'GammaTGamma5',
'SigmaXT',
'SigmaXY',
'SigmaXZ',
'SigmaYT',
'SigmaYZ',
'SigmaZT']:
pe.dirac.Grid_gamma(gamma)
with pytest.raises(Exception):
pe.dirac.Grid_gamma('Not a gamma matrix')

View file

@ -9,6 +9,43 @@ import pytest
np.random.seed(0)
def test_Obs_exceptions():
with pytest.raises(Exception):
pe.Obs([np.random.rand(10)], ['1', '2'])
with pytest.raises(Exception):
pe.Obs([np.random.rand(10)], ['1'], idl=[])
with pytest.raises(Exception):
pe.Obs([np.random.rand(10), np.random.rand(10)], ['1', '1'])
with pytest.raises(Exception):
pe.Obs([np.random.rand(10), np.random.rand(10)], ['1', 1])
with pytest.raises(Exception):
pe.Obs([np.random.rand(10)], [1])
with pytest.raises(Exception):
pe.Obs([np.random.rand(4)], ['name'])
my_obs = pe.Obs([np.random.rand(6)], ['name'])
my_obs._value = 0.0
my_obs.details()
with pytest.raises(Exception):
my_obs.plot_tauint()
with pytest.raises(Exception):
my_obs.plot_rho()
with pytest.raises(Exception):
my_obs.plot_rep_dist()
with pytest.raises(Exception):
my_obs.plot_piechart()
with pytest.raises(Exception):
my_obs.gamma_method(S='2.3')
with pytest.raises(Exception):
my_obs.gamma_method(tau_exp=2.3)
my_obs.gamma_method()
my_obs.details()
my_obs += pe.Obs([np.random.rand(6)], ['name2|r1'])
my_obs += pe.Obs([np.random.rand(6)], ['name2|r2'])
my_obs.gamma_method()
my_obs.details()
def test_dump():
value = np.random.normal(5, 10)
dvalue = np.abs(np.random.normal(0, 1))
@ -311,6 +348,7 @@ def test_overloaded_functions():
def test_utils():
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)
for tau_exp in [0, 5]:
my_obs.gamma_method(tau_exp=tau_exp)
my_obs.tag = "Test description"
@ -325,6 +363,8 @@ def test_utils():
my_obs.plot_piechart()
assert my_obs > (my_obs - 1)
assert my_obs < (my_obs + 1)
float(my_obs)
str(my_obs)
def test_cobs():