From 338bf8906a4097aab6acb840c708fde598356183 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Fri, 24 Jun 2022 12:28:49 +0100 Subject: [PATCH] refactor: maintainability issues in tests fixed. --- tests/correlators_test.py | 4 ++-- tests/fits_test.py | 7 +++---- tests/linalg_test.py | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/correlators_test.py b/tests/correlators_test.py index 3cfa230b..c1c79975 100644 --- a/tests/correlators_test.py +++ b/tests/correlators_test.py @@ -249,9 +249,9 @@ def test_matrix_corr(): def test_corr_none_entries(): 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]]) - x = [l, n] + x = [la, n] matr = pe.Corr(x) matr.projected(np.asarray([1.0, 0.0])) diff --git a/tests/fits_test.py b/tests/fits_test.py index 8dd6677d..6cb806d2 100644 --- a/tests/fits_test.py +++ b/tests/fits_test.py @@ -194,7 +194,7 @@ def test_linear_fit_guesses(): lin_func = lambda a, x: a[0] + a[1] * x with pytest.raises(Exception): 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): 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]): 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 fr = pe.least_squares(np.arange(1, 4), dat, func) fr.gamma_method(S=0) @@ -448,8 +448,7 @@ def test_correlated_fit_vs_jackknife(): x_val = np.arange(1, 6, 2) 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) - [o.gamma_method(S=0) for o in dat]; - dat + [o.gamma_method(S=0) for o in dat] func = lambda a, x: a[0] * x + a[1] * x ** 2 fr = pe.least_squares(x_val, dat, func, correlated_fit=True, silent=True) [o.gamma_method(S=0) for o in fr] diff --git a/tests/linalg_test.py b/tests/linalg_test.py index 09db0ac5..59dc898c 100644 --- a/tests/linalg_test.py +++ b/tests/linalg_test.py @@ -258,8 +258,8 @@ def test_complex_matrix_inverse(): inverse_matrix = np.linalg.inv(matrix) inverse_obs_matrix = pe.linalg.inv(obs_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].imag, inverse_obs_matrix[n, m].imag.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) def test_matrix_functions():