Skip to content
Snippets Groups Projects
Commit bac2aaec authored by Bert Palm's avatar Bert Palm 🎇
Browse files

adjusted saqc calls to customRoller

parent cfcb20a0
No related branches found
No related tags found
3 merge requests!193Release 1.4,!188Release 1.4,!166Rolling rework fixes
Pipeline #11699 passed with stage
in 6 minutes and 11 seconds
......@@ -50,7 +50,7 @@ def constants_flagBasic(data, field, flagger, thresh, window, **kwargs):
# min_periods=2 ensures that at least two non-nan values are present
# in each window and also min() == max() == d[i] is not possible.
kws = dict(window=window, min_periods=2)
kws = dict(window=window, min_periods=2, expand=False)
# find all consecutive constant values in one direction...
r = customRoller(d, **kws)
......
......@@ -512,13 +512,11 @@ def modelling_changePointCluster(data, field, flagger, stat_func, thresh_func, b
if reduce_window is None:
reduce_window = f"{int(pd.Timedelta(bwd_window).total_seconds() + pd.Timedelta(fwd_window).total_seconds())}s"
# native pandas.rolling also fails
data_ser.rolling(window=bwd_window, min_periods=min_periods_bwd, closed=closed)
roller = customRoller(data_ser, window=bwd_window, min_periods=min_periods_bwd, closed=closed)
bwd_start, bwd_end = roller.window.get_window_bounds()
roller = customRoller(data_ser, window=bwd_window)
bwd_start, bwd_end = roller.window.get_window_bounds(len(data_ser), min_periods=min_periods_bwd, closed=closed)
roller = customRoller(data_ser, window=fwd_window, min_periods=min_periods_fwd, closed=closed, forward=True)
fwd_start, fwd_end = roller.window.get_window_bounds()
roller = customRoller(data_ser, window=fwd_window, forward=True)
fwd_start, fwd_end = roller.window.get_window_bounds(len(data_ser), min_periods=min_periods_fwd, closed=closed)
min_mask = ~((fwd_end - fwd_start <= min_periods_fwd) | (bwd_end - bwd_start <= min_periods_bwd))
fwd_end = fwd_end[min_mask]
......@@ -560,7 +558,7 @@ def modelling_changePointCluster(data, field, flagger, stat_func, thresh_func, b
detected = pd.Series(True, index=det_index)
if reduce_window is not False:
l = detected.shape[0]
roller = customRoller(detected, window=reduce_window, min_periods=1, closed='both', center=True)
roller = customRoller(detected, window=reduce_window)
start, end = roller.window.get_window_bounds(num_values=l, min_periods=1, closed='both', center=True)
detected = _reduceCPCluster(stat_arr[result_arr], thresh_arr[result_arr], start, end, reduce_func, l)
......
......@@ -324,9 +324,9 @@ def customRoller(obj, window, min_periods=None, # aka minimum non-nan values
Notes
-----
If for some reason the start and end numeric indices of the window are needed, one can call
`start, end = customRoller(obj, ...).window.get_window_bounds()`, which return two arrays,
holding the start and end indices. Any passed (allowed) parameter to `get_window_bounds()` is
ignored and the arguments that was passed to `customRoller()` beforehand will be used instead.
`start, end = customRoller(obj, window).window.get_window_bounds(num_values, min_periods)`,
which return two np.arrays, that are holding the start and end indices. Fill at least all
parameter which are shown in the example.
See Also
--------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment