Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_calculate_drho for large time separations #157

Merged
merged 6 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ jobs:
- name: flake8 Lint
uses: py-actions/flake8@v2
with:
ignore: "E501"
ignore: "E501,W503"
exclude: "__init__.py, input/__init__.py"
path: "pyerrors"
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 --ignore=E501,W503 --exclude=__init__.py pyerrors
```
Please make sure that all tests are passed for a new pull requests.
9 changes: 6 additions & 3 deletions pyerrors/obs.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,10 @@ def _parse_kwarg(kwarg_name):
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:
Expand Down Expand Up @@ -320,8 +323,8 @@ def _compute_drho(i):
# 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)
Expand Down
10 changes: 10 additions & 0 deletions tests/obs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1146,3 +1146,13 @@ 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()

o.idl['test'] = [1, 5] + list(range(7, 2002, 2))
no = np.NaN * o
no.gamma_method()