From 1b22d34156efd0ff2efd39f1576f0a2a37d35fbf Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Wed, 19 Oct 2022 11:57:16 +0100 Subject: [PATCH 1/5] fix: dtauint fixed for irregular gapped chains. --- pyerrors/obs.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pyerrors/obs.py b/pyerrors/obs.py index c8373d5e..9c99f617 100644 --- a/pyerrors/obs.py +++ b/pyerrors/obs.py @@ -267,18 +267,6 @@ class Obs: self.e_windowsize[e_name] = 0 continue - self.e_rho[e_name] = e_gamma[e_name][:w_max] / e_gamma[e_name][0] - self.e_n_tauint[e_name] = np.cumsum(np.concatenate(([0.5], self.e_rho[e_name][1:]))) - # Make sure no entry of tauint is smaller than 0.5 - self.e_n_tauint[e_name][self.e_n_tauint[e_name] <= 0.5] = 0.5 + np.finfo(np.float64).eps - # hep-lat/0306017 eq. (42) - self.e_n_dtauint[e_name] = self.e_n_tauint[e_name] * 2 * np.sqrt(np.abs(np.arange(w_max) + 0.5 - self.e_n_tauint[e_name]) / e_N) - 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] - self.e_drho[e_name][i] = np.sqrt(np.sum(tmp ** 2) / e_N) - gaps = [] for r_name in e_content[e_name]: if isinstance(self.idl[r_name], range): @@ -291,6 +279,18 @@ class Obs: else: gapsize = gaps[0] + self.e_rho[e_name] = e_gamma[e_name][:w_max] / e_gamma[e_name][0] + self.e_n_tauint[e_name] = np.cumsum(np.concatenate(([0.5], self.e_rho[e_name][1:]))) + # Make sure no entry of tauint is smaller than 0.5 + self.e_n_tauint[e_name][self.e_n_tauint[e_name] <= 0.5] = 0.5 + np.finfo(np.float64).eps + # hep-lat/0306017 eq. (42) + self.e_n_dtauint[e_name] = self.e_n_tauint[e_name] * 2 * np.sqrt(np.abs(np.arange(w_max) / gapsize + 0.5 - self.e_n_tauint[e_name]) / e_N) + 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] + self.e_drho[e_name][i] = np.sqrt(np.sum(tmp ** 2) / e_N) + _compute_drho(gapsize) if self.tau_exp[e_name] > 0: texp = self.tau_exp[e_name] From e3f7baa667bc6b06e5d1ccd26b59ea2201ee7953 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Wed, 19 Oct 2022 12:02:36 +0100 Subject: [PATCH 2/5] tests: test for gapped irregular dtauint added. --- tests/obs_test.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/obs_test.py b/tests/obs_test.py index 29ee67ba..5c6565fe 100644 --- a/tests/obs_test.py +++ b/tests/obs_test.py @@ -669,6 +669,23 @@ def test_gamma_method_irregular(): assert np.isclose(tau_a, tau_b) +def test_irregular_gapped_dtauint(): + my_idl = list(range(0, 5010, 10)) + my_idl.remove(400) + my_idl2 = list(range(0, 501, 1)) + my_idl2.remove(40) + + my_data = np.random.normal(1.1, 0.2, 500) + obs = pe.Obs([my_data], ["B1"], idl=[my_idl]) + obs.gamma_method() + + obs2 = pe.Obs([my_data], ["B2"], idl=[my_idl2]) + obs2.gamma_method() + + assert np.isclose(obs.e_tauint["B1"], obs2.e_tauint["B2"]) + assert np.isclose(obs.e_dtauint["B1"], obs2.e_dtauint["B2"]) + + def test_covariance_is_variance(): value = np.random.normal(5, 10) dvalue = np.abs(np.random.normal(0, 1)) From 3869c1ed3bffba980aad66e1062b2557a317f705 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Wed, 19 Oct 2022 12:48:18 +0100 Subject: [PATCH 3/5] build: removed unnecessary dependency pysqlite3. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b68e0408..3b570614 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ setup(name='pyerrors', license="MIT", packages=find_packages(), python_requires='>=3.6.0', - install_requires=['numpy>=1.19', 'autograd>=1.5', 'numdifftools', 'matplotlib>=3.3', 'scipy>=1.5', 'iminuit>=2', 'h5py>=3', 'lxml>=4', 'python-rapidjson>=1', 'pandas>=1.1', 'pysqlite3>=0.4'], + install_requires=['numpy>=1.19', 'autograd>=1.5', 'numdifftools', 'matplotlib>=3.3', 'scipy>=1.5', 'iminuit>=2', 'h5py>=3', 'lxml>=4', 'python-rapidjson>=1', 'pandas>=1.1'], classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Science/Research', From d5d75dae30bacc6cb3d53a7dd8fe297eda639b78 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Wed, 19 Oct 2022 12:57:44 +0100 Subject: [PATCH 4/5] build: build requirements updated to latest version compatible with python 3.7 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 3b570614..ad1aa746 100644 --- a/setup.py +++ b/setup.py @@ -24,8 +24,8 @@ setup(name='pyerrors', author_email='fabian.joswig@ed.ac.uk', license="MIT", packages=find_packages(), - python_requires='>=3.6.0', - install_requires=['numpy>=1.19', 'autograd>=1.5', 'numdifftools', 'matplotlib>=3.3', 'scipy>=1.5', 'iminuit>=2', 'h5py>=3', 'lxml>=4', 'python-rapidjson>=1', 'pandas>=1.1'], + python_requires='>=3.7.0', + install_requires=['numpy>=1.19', 'autograd>=1.5', 'numdifftools', 'matplotlib>=3.5', 'scipy>=1.7', 'iminuit>=2.17', 'h5py>=3.7', 'lxml>=4.9', 'python-rapidjson>=1.9', 'pandas>=1.1'], classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Science/Research', From 4c98bed2ad82f7572399c702cc704330abdb2a1d Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Wed, 19 Oct 2022 13:03:23 +0100 Subject: [PATCH 5/5] ci: fail fast strategy for pytest workflow changed to false. --- .github/workflows/pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 5e215110..3a8563f4 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -13,7 +13,7 @@ jobs: pytest: runs-on: ${{ matrix.os }} strategy: - fail-fast: true + fail-fast: false matrix: os: [ubuntu-latest] python-version: ["3.7", "3.8", "3.9", "3.10"]