diff --git a/CHANGELOG.md b/CHANGELOG.md index 871d5797bb677604c14bba3abd9c6adb2b9f6c5b..17ace3abfe08b9a40b877a35b1e56a00f75f4ecc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ SPDX-License-Identifier: GPL-3.0-or-later ### Fixed - `func` arguments in text configurations were not parsed correctly - fail on duplicated arguments to test methods +- `reample` was not writing meta entries ## [2.3.0](https://git.ufz.de/rdm-software/saqc/-/tags/v2.3.0) - 2023-01-17 [List of commits](https://git.ufz.de/rdm-software/saqc/-/compare/v2.2.1...v2.3.0) diff --git a/saqc/funcs/resampling.py b/saqc/funcs/resampling.py index 52b2a5322fd0e9f8ac20d25d969aaea731292471..7ec5e4b8657582b3b4c75b5d26e9d5159f3940f2 100644 --- a/saqc/funcs/resampling.py +++ b/saqc/funcs/resampling.py @@ -15,6 +15,7 @@ import numpy as np import pandas as pd from typing_extensions import Literal +from saqc.constants import UNFLAGGED from saqc.core import register from saqc.funcs.interpolation import _SUPPORTED_METHODS from saqc.lib.tools import evalFreqStr, filterKwargs, getFreqDelta, isflagged @@ -238,6 +239,24 @@ class ResamplingMixin: func=aggregate2Freq, func_kws=kws, ) + meta = { + "func": "resample", + "args": (), + "kwargs": { + "freq": freq, + "func": func, + "method": method, + "maxna": maxna, + "maxna_group": maxna_group, + "maxna_flags": maxna_flags, + "maxna_group_flags": maxna_group_flags, + "flag_func": flag_func, + "freq_check": freq_check, + **kwargs, + }, + } + flagcol = pd.Series(UNFLAGGED, index=history.index) + history.append(flagcol, meta) self._data[field] = datcol self._flags.history[field] = history diff --git a/tests/funcs/test_resampling.py b/tests/funcs/test_resampling.py index 860ef654c32208849af9bce4eb089319c0958087..e945bd80d8c5d12eb730329c3bc69df6967fd74e 100644 --- a/tests/funcs/test_resampling.py +++ b/tests/funcs/test_resampling.py @@ -113,6 +113,7 @@ def test_resampleAggregateInvert(data, method, freq, expected): qc = qc.resample(field_aggregated, freq, func=np.sum, method=method) assert qc._data[field_aggregated].index.freq == pd.Timedelta(freq) assert qc._data[field_aggregated].equals(expected) + assert qc._flags.history[field_aggregated].meta[-1]["func"] == "resample" checkInvariants(qc._data, qc._flags, field_aggregated, identical=True) qc = qc.concatFlags(field_aggregated, target=field, method="inverse_" + method)