From 55f5222db192fbb7c22c6348e43d1ddd064bc22d Mon Sep 17 00:00:00 2001
From: Peter Luenenschloss <peter.luenenschloss@ufz.de>
Date: Fri, 2 Oct 2020 15:20:20 +0200
Subject: [PATCH] added diff only feature to all but the continous flagger

---
 saqc/flagger/baseflagger.py | 4 ++++
 saqc/flagger/dmpflagger.py  | 5 +++++
 saqc/funcs/functions.py     | 4 ++--
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/saqc/flagger/baseflagger.py b/saqc/flagger/baseflagger.py
index b3c576e24..d6f4aeb85 100644
--- a/saqc/flagger/baseflagger.py
+++ b/saqc/flagger/baseflagger.py
@@ -152,6 +152,10 @@ class BaseFlagger(ABC):
         assertScalar("field", field, optional=False)
         flag = self.BAD if flag is None else flag
 
+        if kwargs.get('diff_only', False):
+            del kwargs['diff_only']
+            self.setFlags(field, force=True, inplace=True, flag=self.UNFLAGGED, **kwargs)
+
         if force:
             row_indexer = slice(None) if loc is None else loc
         else:
diff --git a/saqc/flagger/dmpflagger.py b/saqc/flagger/dmpflagger.py
index 9e5442577..480e7a8bd 100644
--- a/saqc/flagger/dmpflagger.py
+++ b/saqc/flagger/dmpflagger.py
@@ -110,6 +110,11 @@ class DmpFlagger(CategoricalFlagger):
         assertScalar("field", field, optional=False)
 
         flag = self.BAD if flag is None else flag
+
+        if kwargs.get('diff_only', False):
+            del kwargs['diff_only']
+            self.setFlags(field, force=True, inplace=True, flag=self.UNFLAGGED, **kwargs)
+
         comment = json.dumps(
             {"comment": comment,
              "commit": self.project_version,
diff --git a/saqc/funcs/functions.py b/saqc/funcs/functions.py
index a10dbb4aa..699f91bef 100644
--- a/saqc/funcs/functions.py
+++ b/saqc/funcs/functions.py
@@ -1076,7 +1076,7 @@ def _reduceCPCluster(stat_arr, thresh_arr, start, end, obj_func, num_val, out_ar
 @register(masking='field')
 def flagChangePoints(data, field, flagger, stat_func, thresh_func, bwd_window, min_periods_bwd,
                      fwd_window=None, min_periods_fwd=None, closed='both', try_to_jit=True,
-                     agg_range=None, reduce_func=lambda x, y: x.argmax()):
+                     agg_range=None, reduce_func=lambda x, y: x.argmax(), **kwargs):
     """
     Function for change point detection based on sliding window search.
 
@@ -1152,5 +1152,5 @@ def flagChangePoints(data, field, flagger, stat_func, thresh_func, bwd_window, m
                                 detected.shape[0], out_arr)
 
     det_index = det_index[detected]
-    flagger = flagger.setFlags(field, loc=det_index)
+    flagger = flagger.setFlags(field, loc=det_index, **kwargs)
     return data, flagger
\ No newline at end of file
-- 
GitLab