mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 11:33:42 +02:00
Fix another edge case in _compute_drho (#194)
* tests: failing test for compute_drho edge case added. * tests: example file for failing compute_drho added. * tests: assertion that dvalue stays the same added to compute drho test. * fix: another edge case in computation of drho fixed.
This commit is contained in:
parent
07c8a1b71d
commit
c6d04cf88b
3 changed files with 6 additions and 1 deletions
|
@ -278,7 +278,7 @@ class Obs:
|
||||||
|
|
||||||
def _compute_drho(i):
|
def _compute_drho(i):
|
||||||
tmp = (self.e_rho[e_name][i + 1:w_max]
|
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 - (2 * w_max) // 2):-1],
|
+ np.concatenate([self.e_rho[e_name][i - 1:None if i - (w_max - 1) // 2 <= 0 else (2 * i - (2 * w_max) // 2):-1],
|
||||||
self.e_rho[e_name][1:max(1, w_max - 2 * i)]])
|
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])
|
- 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)
|
self.e_drho[e_name][i] = np.sqrt(np.sum(tmp ** 2) / e_N)
|
||||||
|
|
BIN
tests/data/compute_drho_fails.json.gz
Normal file
BIN
tests/data/compute_drho_fails.json.gz
Normal file
Binary file not shown.
|
@ -1282,3 +1282,8 @@ def test_f_string_obs():
|
||||||
print(f"{o1:+3}")
|
print(f"{o1:+3}")
|
||||||
print(f"{o1:-1}")
|
print(f"{o1:-1}")
|
||||||
print(f"{o1: 8}")
|
print(f"{o1: 8}")
|
||||||
|
|
||||||
|
def test_compute_drho_fails():
|
||||||
|
obs = pe.input.json.load_json("tests/data/compute_drho_fails.json.gz")
|
||||||
|
obs.gm()
|
||||||
|
assert np.isclose(obs.dvalue, 0.0022150779611891094)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue