mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 11:33:42 +02:00
refactor: maintainability issues in tests fixed.
This commit is contained in:
parent
07d947d5b1
commit
338bf8906a
3 changed files with 7 additions and 8 deletions
|
@ -249,9 +249,9 @@ def test_matrix_corr():
|
||||||
|
|
||||||
def test_corr_none_entries():
|
def test_corr_none_entries():
|
||||||
a = pe.pseudo_Obs(1.0, 0.1, 'a')
|
a = pe.pseudo_Obs(1.0, 0.1, 'a')
|
||||||
l = np.asarray([[a, a], [a, a]])
|
la = np.asarray([[a, a], [a, a]])
|
||||||
n = np.asarray([[None, None], [None, None]])
|
n = np.asarray([[None, None], [None, None]])
|
||||||
x = [l, n]
|
x = [la, n]
|
||||||
matr = pe.Corr(x)
|
matr = pe.Corr(x)
|
||||||
matr.projected(np.asarray([1.0, 0.0]))
|
matr.projected(np.asarray([1.0, 0.0]))
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ def test_linear_fit_guesses():
|
||||||
lin_func = lambda a, x: a[0] + a[1] * x
|
lin_func = lambda a, x: a[0] + a[1] * x
|
||||||
with pytest.raises(Exception):
|
with pytest.raises(Exception):
|
||||||
pe.least_squares(xvals, yvals, lin_func)
|
pe.least_squares(xvals, yvals, lin_func)
|
||||||
[o.gamma_method() for o in yvals];
|
[o.gamma_method() for o in yvals]
|
||||||
with pytest.raises(Exception):
|
with pytest.raises(Exception):
|
||||||
pe.least_squares(xvals, yvals, lin_func, initial_guess=[5])
|
pe.least_squares(xvals, yvals, lin_func, initial_guess=[5])
|
||||||
|
|
||||||
|
@ -414,7 +414,7 @@ def test_fit_vs_jackknife():
|
||||||
|
|
||||||
for i, cov in enumerate([cov1, cov2, cov3]):
|
for i, cov in enumerate([cov1, cov2, cov3]):
|
||||||
dat = pe.misc.gen_correlated_data(np.arange(1, 4), cov, 'test', 0.5, samples=samples)
|
dat = pe.misc.gen_correlated_data(np.arange(1, 4), cov, 'test', 0.5, samples=samples)
|
||||||
[o.gamma_method(S=0) for o in dat];
|
[o.gamma_method(S=0) for o in dat]
|
||||||
func = lambda a, x: a[0] + a[1] * x
|
func = lambda a, x: a[0] + a[1] * x
|
||||||
fr = pe.least_squares(np.arange(1, 4), dat, func)
|
fr = pe.least_squares(np.arange(1, 4), dat, func)
|
||||||
fr.gamma_method(S=0)
|
fr.gamma_method(S=0)
|
||||||
|
@ -448,8 +448,7 @@ def test_correlated_fit_vs_jackknife():
|
||||||
x_val = np.arange(1, 6, 2)
|
x_val = np.arange(1, 6, 2)
|
||||||
for i, cov in enumerate([cov1, cov2, cov3]):
|
for i, cov in enumerate([cov1, cov2, cov3]):
|
||||||
dat = pe.misc.gen_correlated_data(x_val + x_val ** 2 + np.random.normal(0.0, 0.1, 3), cov, 'test', 0.5, samples=samples)
|
dat = pe.misc.gen_correlated_data(x_val + x_val ** 2 + np.random.normal(0.0, 0.1, 3), cov, 'test', 0.5, samples=samples)
|
||||||
[o.gamma_method(S=0) for o in dat];
|
[o.gamma_method(S=0) for o in dat]
|
||||||
dat
|
|
||||||
func = lambda a, x: a[0] * x + a[1] * x ** 2
|
func = lambda a, x: a[0] * x + a[1] * x ** 2
|
||||||
fr = pe.least_squares(x_val, dat, func, correlated_fit=True, silent=True)
|
fr = pe.least_squares(x_val, dat, func, correlated_fit=True, silent=True)
|
||||||
[o.gamma_method(S=0) for o in fr]
|
[o.gamma_method(S=0) for o in fr]
|
||||||
|
|
|
@ -258,8 +258,8 @@ def test_complex_matrix_inverse():
|
||||||
inverse_matrix = np.linalg.inv(matrix)
|
inverse_matrix = np.linalg.inv(matrix)
|
||||||
inverse_obs_matrix = pe.linalg.inv(obs_matrix)
|
inverse_obs_matrix = pe.linalg.inv(obs_matrix)
|
||||||
for (n, m), entry in np.ndenumerate(inverse_matrix):
|
for (n, m), entry in np.ndenumerate(inverse_matrix):
|
||||||
assert np.isclose(inverse_matrix[n, m].real, inverse_obs_matrix[n, m].real.value)
|
assert np.isclose(inverse_matrix[n, m].real, inverse_obs_matrix[n, m].real.value)
|
||||||
assert np.isclose(inverse_matrix[n, m].imag, inverse_obs_matrix[n, m].imag.value)
|
assert np.isclose(inverse_matrix[n, m].imag, inverse_obs_matrix[n, m].imag.value)
|
||||||
|
|
||||||
|
|
||||||
def test_matrix_functions():
|
def test_matrix_functions():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue