From 82adb215be1405838842ace29def6dd33e8e5b4f Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Sun, 26 Feb 2023 18:49:54 +0000 Subject: [PATCH 1/6] fix: _compute_drho now also works for i > w_max / 2. --- pyerrors/obs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyerrors/obs.py b/pyerrors/obs.py index 0bb09ec3..b3c51e0f 100644 --- a/pyerrors/obs.py +++ b/pyerrors/obs.py @@ -289,7 +289,9 @@ class Obs: self.e_n_dtauint[e_name][0] = 0.0 def _compute_drho(i): - tmp = self.e_rho[e_name][i + 1:w_max] + np.concatenate([self.e_rho[e_name][i - 1::-1], self.e_rho[e_name][1:w_max - 2 * i]]) - 2 * self.e_rho[e_name][i] * self.e_rho[e_name][1:w_max - i] + tmp = (self.e_rho[e_name][i + 1:w_max] + + np.concatenate([self.e_rho[e_name][i - 1:None if i - w_max // 2 < 0 else 2 * (i - w_max // 2):-1], self.e_rho[e_name][1:max(1, w_max - 2 * i)]]) + - 2 * self.e_rho[e_name][i] * self.e_rho[e_name][1:w_max - i]) self.e_drho[e_name][i] = np.sqrt(np.sum(tmp ** 2) / e_N) if self.tau_exp[e_name] > 0: From 3b773b7b520f468ee75e22fafe73bec5281716ae Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Sun, 26 Feb 2023 18:55:16 +0000 Subject: [PATCH 2/6] ci: default ignore options added to flake8 workflow and CONTRIBUTING.md updated. --- .github/workflows/flake8.yml | 2 +- CONTRIBUTING.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml index c0a3629b..b4beb4b4 100644 --- a/.github/workflows/flake8.yml +++ b/.github/workflows/flake8.yml @@ -21,6 +21,6 @@ jobs: - name: flake8 Lint uses: py-actions/flake8@v2 with: - ignore: "E501" + ignore: "E501,E121,E123,E126,E226,E24,E704,W503,W504" exclude: "__init__.py, input/__init__.py" path: "pyerrors" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8d803e4a..22aa0798 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,6 +33,6 @@ pytest --cov=pyerrors --cov-report html ``` The linter `flake8` is executed with the command ``` -flake8 --ignore=E501 --exclude=__init__.py pyerrors +flake8 --extend-ignore=E501 --exclude=__init__.py pyerrors ``` Please make sure that all tests are passed for a new pull requests. From 8bc204fc31e90809841c351af905d18b9f057fae Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Sun, 26 Feb 2023 18:56:46 +0000 Subject: [PATCH 3/6] tests: nan obs test added. --- tests/obs_test.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/obs_test.py b/tests/obs_test.py index 0a62bab1..3f65ecee 100644 --- a/tests/obs_test.py +++ b/tests/obs_test.py @@ -1146,3 +1146,9 @@ def test_non_overlapping_operations_different_lengths(): assert np.isclose(res1.value, res2.value) assert np.isclose(res1.dvalue, res2.dvalue, rtol=0.01) + + +def test_nan_obs(): + o = pe.pseudo_Obs(1, .1, 'test') + no = np.nan * o + no.gamma_method() From 854b46c5b405af47e60a00e745e60378deffad7f Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Sun, 26 Feb 2023 18:58:54 +0000 Subject: [PATCH 4/6] chore: reformat in _compute_drho. --- pyerrors/obs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyerrors/obs.py b/pyerrors/obs.py index b3c51e0f..2dcab477 100644 --- a/pyerrors/obs.py +++ b/pyerrors/obs.py @@ -290,7 +290,8 @@ class Obs: def _compute_drho(i): tmp = (self.e_rho[e_name][i + 1:w_max] - + np.concatenate([self.e_rho[e_name][i - 1:None if i - w_max // 2 < 0 else 2 * (i - w_max // 2):-1], self.e_rho[e_name][1:max(1, w_max - 2 * i)]]) + + np.concatenate([self.e_rho[e_name][i - 1:None if i - w_max // 2 < 0 else 2 * (i - w_max // 2):-1], + self.e_rho[e_name][1:max(1, w_max - 2 * i)]]) - 2 * self.e_rho[e_name][i] * self.e_rho[e_name][1:w_max - i]) self.e_drho[e_name][i] = np.sqrt(np.sum(tmp ** 2) / e_N) From e85d7dfde636264eb2708b339fb98a6a3479b07a Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Sun, 26 Feb 2023 19:07:22 +0000 Subject: [PATCH 5/6] ci: flake8 workflow made more strict again (and CONTRIBUTING.md updated.) --- .github/workflows/flake8.yml | 2 +- CONTRIBUTING.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml index b4beb4b4..d931f241 100644 --- a/.github/workflows/flake8.yml +++ b/.github/workflows/flake8.yml @@ -21,6 +21,6 @@ jobs: - name: flake8 Lint uses: py-actions/flake8@v2 with: - ignore: "E501,E121,E123,E126,E226,E24,E704,W503,W504" + ignore: "E501,W503" exclude: "__init__.py, input/__init__.py" path: "pyerrors" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 22aa0798..b5cd207e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,6 +33,6 @@ pytest --cov=pyerrors --cov-report html ``` The linter `flake8` is executed with the command ``` -flake8 --extend-ignore=E501 --exclude=__init__.py pyerrors +flake8 --ignore=E501,W503 --exclude=__init__.py pyerrors ``` Please make sure that all tests are passed for a new pull requests. From d81d6ea0b8725aebf75f690f6adeaa4c87cebbbc Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Mon, 27 Feb 2023 21:43:29 +0000 Subject: [PATCH 6/6] fix: loop range in standard windowing procedure adjusted by gapsize - Test added Co-authored-by: Simon Kuberski --- pyerrors/obs.py | 4 ++-- tests/obs_test.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pyerrors/obs.py b/pyerrors/obs.py index 2dcab477..239efc5c 100644 --- a/pyerrors/obs.py +++ b/pyerrors/obs.py @@ -323,8 +323,8 @@ class Obs: # Standard automatic windowing procedure tau = self.S[e_name] / np.log((2 * self.e_n_tauint[e_name][gapsize::gapsize] + 1) / (2 * self.e_n_tauint[e_name][gapsize::gapsize] - 1)) g_w = np.exp(- np.arange(1, len(tau) + 1) / tau) - tau / np.sqrt(np.arange(1, len(tau) + 1) * e_N) - for n in range(1, w_max): - if g_w[n - 1] < 0 or n >= w_max - 1: + for n in range(1, w_max // gapsize): + if g_w[n - 1] < 0 or n >= w_max // gapsize - 1: _compute_drho(gapsize * n) n *= gapsize self.e_tauint[e_name] = self.e_n_tauint[e_name][n] * (1 + (2 * n / gapsize + 1) / e_N) / (1 + 1 / e_N) # Bias correction hep-lat/0306017 eq. (49) diff --git a/tests/obs_test.py b/tests/obs_test.py index 3f65ecee..824feb77 100644 --- a/tests/obs_test.py +++ b/tests/obs_test.py @@ -1152,3 +1152,7 @@ def test_nan_obs(): o = pe.pseudo_Obs(1, .1, 'test') no = np.nan * o no.gamma_method() + + o.idl['test'] = [1, 5] + list(range(7, 2002, 2)) + no = np.NaN * o + no.gamma_method()