Skip to content

Commit de35332

Browse files
authored
Merge pull request #157 from fjosw/fix/calc_rho_large_t
_calculate_drho for large time separations
2 parents a33c0a2 + d81d6ea commit de35332

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

.github/workflows/flake8.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ jobs:
2121
- name: flake8 Lint
2222
uses: py-actions/flake8@v2
2323
with:
24-
ignore: "E501"
24+
ignore: "E501,W503"
2525
exclude: "__init__.py, input/__init__.py"
2626
path: "pyerrors"

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ pytest --cov=pyerrors --cov-report html
3333
```
3434
The linter `flake8` is executed with the command
3535
```
36-
flake8 --ignore=E501 --exclude=__init__.py pyerrors
36+
flake8 --ignore=E501,W503 --exclude=__init__.py pyerrors
3737
```
3838
Please make sure that all tests are passed for a new pull requests.

pyerrors/obs.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,10 @@ def _parse_kwarg(kwarg_name):
289289
self.e_n_dtauint[e_name][0] = 0.0
290290

291291
def _compute_drho(i):
292-
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]
292+
tmp = (self.e_rho[e_name][i + 1:w_max]
293+
+ np.concatenate([self.e_rho[e_name][i - 1:None if i - w_max // 2 < 0 else 2 * (i - w_max // 2):-1],
294+
self.e_rho[e_name][1:max(1, w_max - 2 * i)]])
295+
- 2 * self.e_rho[e_name][i] * self.e_rho[e_name][1:w_max - i])
293296
self.e_drho[e_name][i] = np.sqrt(np.sum(tmp ** 2) / e_N)
294297

295298
if self.tau_exp[e_name] > 0:
@@ -320,8 +323,8 @@ def _compute_drho(i):
320323
# Standard automatic windowing procedure
321324
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))
322325
g_w = np.exp(- np.arange(1, len(tau) + 1) / tau) - tau / np.sqrt(np.arange(1, len(tau) + 1) * e_N)
323-
for n in range(1, w_max):
324-
if g_w[n - 1] < 0 or n >= w_max - 1:
326+
for n in range(1, w_max // gapsize):
327+
if g_w[n - 1] < 0 or n >= w_max // gapsize - 1:
325328
_compute_drho(gapsize * n)
326329
n *= gapsize
327330
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)

tests/obs_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,3 +1146,13 @@ def test_non_overlapping_operations_different_lengths():
11461146

11471147
assert np.isclose(res1.value, res2.value)
11481148
assert np.isclose(res1.dvalue, res2.dvalue, rtol=0.01)
1149+
1150+
1151+
def test_nan_obs():
1152+
o = pe.pseudo_Obs(1, .1, 'test')
1153+
no = np.nan * o
1154+
no.gamma_method()
1155+
1156+
o.idl['test'] = [1, 5] + list(range(7, 2002, 2))
1157+
no = np.NaN * o
1158+
no.gamma_method()

0 commit comments

Comments
 (0)