diff --git a/CHANGELOG.md b/CHANGELOG.md index ed49fe9a..5ac97253 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. +## [2.8.1] - 2023-06-01 +### Fixed +- `input.pandas` can now deal with columns that only have `None` entries. +- Bug in f-string conversion of `Obs` fixed. +- Bug in edge case of `_compute_drho` fixed. +- Several numpy 1.25 deprecations fixed. + + ## [2.8.0] - 2023-05-21 ### Added - `pyerrors` can now deal with replica with different gapsizes. diff --git a/pyerrors/obs.py b/pyerrors/obs.py index 7d8f9911..d1e4f5c7 100644 --- a/pyerrors/obs.py +++ b/pyerrors/obs.py @@ -278,7 +278,7 @@ 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 - (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)]]) - 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) diff --git a/tests/data/compute_drho_fails.json.gz b/tests/data/compute_drho_fails.json.gz new file mode 100644 index 00000000..3fc335bd Binary files /dev/null and b/tests/data/compute_drho_fails.json.gz differ diff --git a/tests/obs_test.py b/tests/obs_test.py index a77c6863..c8b741c2 100644 --- a/tests/obs_test.py +++ b/tests/obs_test.py @@ -1282,3 +1282,8 @@ def test_f_string_obs(): print(f"{o1:+3}") print(f"{o1:-1}") 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) diff --git a/tests/pandas_test.py b/tests/pandas_test.py index 3a02b97e..f86458f8 100644 --- a/tests/pandas_test.py +++ b/tests/pandas_test.py @@ -46,10 +46,9 @@ def test_nan_df_export_import(tmp_path): my_df.loc[1, "int"] = np.nan for gz in [True, False]: - pe.input.pandas.dump_df(my_df, (tmp_path / 'df_output').as_posix(), gz=gz) - reconstructed_df = pe.input.pandas.load_df((tmp_path / 'df_output').as_posix(), auto_gamma=True, gz=gz) with pytest.warns(UserWarning, match="nan value in column int will be replaced by None"): - warnings.warn("nan value in column int will be replaced by None", UserWarning) + pe.input.pandas.dump_df(my_df, (tmp_path / 'df_output').as_posix(), gz=gz) + reconstructed_df = pe.input.pandas.load_df((tmp_path / 'df_output').as_posix(), auto_gamma=True, gz=gz) assert reconstructed_df.loc[1, "int"] is None assert np.all(reconstructed_df.loc[:, "float"] == my_df.loc[:, "float"]) assert np.all(reconstructed_df.loc[:, "Obs1"] == my_df.loc[:, "Obs1"])