mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 19:43:41 +02:00
Additional GEVP method with errors (#195)
* Added the function error_gevp() to compute the gevp with statistical errors. * Changed method name from error_gevp to error_GEVP and removed automatic gamma method * added auto_gamma to error_GEVP * Specified exceptions in Corr.error_GEVP * Fixed a wrong path. It should be np.linalg.LinAlgError * Added a test for error_GEVP * The tests of error_gevp loads a test matrix * Incorporated eigenvectors with uncertainties in GEVP routine * Cleaned up GEVP routines * Cleaned up breaking change from merge * Released tolerance in test of GEVP * Repaired broken GEVP test --------- Co-authored-by: Simon Kuberski <simon.kuberski@uni-muenster.de>
This commit is contained in:
parent
a8d16631d8
commit
e1a4d0c218
5 changed files with 141 additions and 23 deletions
|
@ -200,17 +200,17 @@ def test_padded_correlator():
|
|||
|
||||
def test_corr_exceptions():
|
||||
obs_a = pe.Obs([np.random.normal(0.1, 0.1, 100)], ['test'])
|
||||
obs_b= pe.Obs([np.random.normal(0.1, 0.1, 99)], ['test'])
|
||||
obs_b = pe.Obs([np.random.normal(0.1, 0.1, 99)], ['test'])
|
||||
with pytest.raises(Exception):
|
||||
pe.Corr([obs_a, obs_b])
|
||||
|
||||
obs_a = pe.Obs([np.random.normal(0.1, 0.1, 100)], ['test'])
|
||||
obs_b= pe.Obs([np.random.normal(0.1, 0.1, 100)], ['test'], idl=[range(1, 200, 2)])
|
||||
obs_b = pe.Obs([np.random.normal(0.1, 0.1, 100)], ['test'], idl=[range(1, 200, 2)])
|
||||
with pytest.raises(Exception):
|
||||
pe.Corr([obs_a, obs_b])
|
||||
|
||||
obs_a = pe.Obs([np.random.normal(0.1, 0.1, 100)], ['test'])
|
||||
obs_b= pe.Obs([np.random.normal(0.1, 0.1, 100)], ['test2'])
|
||||
obs_b = pe.Obs([np.random.normal(0.1, 0.1, 100)], ['test2'])
|
||||
with pytest.raises(Exception):
|
||||
pe.Corr([obs_a, obs_b])
|
||||
|
||||
|
@ -436,6 +436,7 @@ def test_GEVP_solver():
|
|||
sp_vecs = [v / np.sqrt((v.T @ mat2 @ v)) for v in sp_vecs]
|
||||
|
||||
assert np.allclose(sp_vecs, pe.correlators._GEVP_solver(mat1, mat2), atol=1e-14)
|
||||
assert np.allclose(np.abs(sp_vecs), np.abs(pe.correlators._GEVP_solver(mat1, mat2, method='cholesky')))
|
||||
|
||||
|
||||
def test_GEVP_none_entries():
|
||||
|
@ -552,7 +553,7 @@ def test_corr_no_filtering():
|
|||
li = [-pe.pseudo_Obs(.2, .1, 'a', samples=10) for i in range(96)]
|
||||
for i in range(len(li)):
|
||||
li[i].idl['a'] = range(1, 21, 2)
|
||||
c= pe.Corr(li)
|
||||
c = pe.Corr(li)
|
||||
b = pe.pseudo_Obs(1, 1e-11, 'a', samples=30)
|
||||
c *= b
|
||||
assert np.all([c[0].idl == o.idl for o in c])
|
||||
|
@ -572,6 +573,28 @@ def test_corr_symmetric():
|
|||
assert scorr[0] == corr[0]
|
||||
|
||||
|
||||
def test_error_GEVP():
|
||||
corr = pe.input.json.load_json("tests/data/test_matrix_corr.json.gz")
|
||||
t0, ts, state = 3, 6, 0
|
||||
vec_regular = corr.GEVP(t0=t0)[state][ts]
|
||||
vec_errors = corr.GEVP(t0=t0, vector_obs=True, auto_gamma=True)[state][ts]
|
||||
vec_regular_chol = corr.GEVP(t0=t0, method='cholesky')[state][ts]
|
||||
print(vec_errors)
|
||||
print(type(vec_errors[0]))
|
||||
assert(np.isclose(np.asarray([e.value for e in vec_errors]), vec_regular).all())
|
||||
assert(all([e.dvalue > 0. for e in vec_errors]))
|
||||
|
||||
projected_regular = corr.projected(vec_regular).content[ts + 1][0]
|
||||
projected_errors = corr.projected(vec_errors).content[ts + 1][0]
|
||||
projected_regular.gamma_method()
|
||||
projected_errors.gamma_method()
|
||||
assert(projected_errors.dvalue > projected_regular.dvalue)
|
||||
assert(corr.GEVP(t0, vector_obs=True)[state][42] is None)
|
||||
|
||||
assert(np.isclose(vec_regular_chol, vec_regular).all())
|
||||
assert(np.isclose(corr.GEVP(t0=t0, state=state)[ts], vec_regular).all())
|
||||
|
||||
|
||||
def test_corr_array_ndim1_init():
|
||||
y = [pe.pseudo_Obs(2 + np.random.normal(0.0, 0.1), .1, 't') for i in np.arange(5)]
|
||||
cc1 = pe.Corr(y)
|
||||
|
@ -688,7 +711,6 @@ def test_matrix_trace():
|
|||
for el in corr.trace():
|
||||
assert el == 0
|
||||
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
corr.item(0, 0).trace()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue