diff --git a/CHANGELOG.md b/CHANGELOG.md index 3683b4d037abe18c16383245252cd3b3d00e24e4..900d0a67b28e0565e976f971ed8e19aff9eb252e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog All notable changes to this project will be documented in this file. +## v0.6.9 - 2025-04-04 - fixed bug in trends/moving_block_bootstrap + +### technical: +* when calculating a trend on a timeseries which is not complete, the method +`moving_block_bootstrap` may throw a `ValueError` based on randomly chosen blocks + ## v0.6.8 - 2025-03-07 - bugfix in time harmonizing ## v0.6.7 - 2025-02-21 - fixed output format diff --git a/dist/toarstats-0.6.9-py3-none-any.whl b/dist/toarstats-0.6.9-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..3364d3cf699f596787d59f996ea5449533a59f82 Binary files /dev/null and b/dist/toarstats-0.6.9-py3-none-any.whl differ diff --git a/setup.cfg b/setup.cfg index bdd4fbc3f9ff610553a4f00e5dd10c8bf8f0966b..b1e5ccd2c9c0ef40465d7a533899cc6ae9295d37 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = toarstats -version = 0.6.8 +version = 0.6.9 author = Niklas Selke, Martin Schultz, Max Lensing author_email = n.selke@fz-juelich.de, m.schultz@fz-juelich.de, m.lensing@fz-juelich.de description = Collection of statistics for the TOAR community diff --git a/toarstats/trends/utils.py b/toarstats/trends/utils.py index bd6167aff44a3b6165fe100e0fd850d940328eb1..650cf99d02c60bd8fabb6384a58936fd7ba5700c 100644 --- a/toarstats/trends/utils.py +++ b/toarstats/trends/utils.py @@ -63,9 +63,12 @@ def moving_block_bootstrap(method, data, quantile=None, num_samples=1000): for _ in range(num_samples): bn = rng.choice(len(blocks), nblocks) samp_data = data.iloc[blocks[bn].flatten()] - if method == "quant": - mod = smf.quantreg("value~datetime", samp_data).fit(q=quantile) - else: - mod = smf.ols("value~datetime", samp_data).fit(method="qr") + try: + if method == "quant": + mod = smf.quantreg("value~datetime", samp_data).fit(q=quantile) + else: + mod = smf.ols("value~datetime", samp_data).fit(method="qr") + except ValueError: + continue samples.append(mod.params) return samples