diff --git a/saqc/flagger/history.py b/saqc/flagger/history.py index 0db2c218eec6cc1f0039eaf9c8f71df5977e701c..9eeb9aa9fa899bc98a30548a4674e765f3f7f8ca 100644 --- a/saqc/flagger/history.py +++ b/saqc/flagger/history.py @@ -230,27 +230,20 @@ class History: if n > len(self): raise ValueError(f"'n={n}' cannot be greater than columns in the FH") - # shortcut - if len(self) == n: - s = self.max() - self.hist = pd.DataFrame() - self.mask = pd.DataFrame() - - else: - # calc the squeezed series. - # we dont have to care about any forced series - # because anytime force was given, the False's in - # the mask were propagated back over the whole FH - mask = self.mask.iloc[:, -n:] - hist = self.hist.iloc[:, -n:] - s = hist[mask].max(axis=1) - - # slice self down - # this may leave us in an unstable state, because - # the last column may not is entirely True, but - # the following append, will fix this - self.hist = self.hist.iloc[:, :-n] - self.mask = self.mask.iloc[:, :-n] + # calc the squeezed series. + # we dont have to care about any forced series + # because anytime force was given, the False's in + # the mask were propagated back over the whole FH + mask = self.mask.iloc[:, -n:] + hist = self.hist.iloc[:, -n:] + s = hist[mask].max(axis=1) + + # slice self down + # this may leave us in an unstable state, because + # the last column maybe is not entirely True, but + # the following append, will fix this + self.hist = self.hist.iloc[:, :-n] + self.mask = self.mask.iloc[:, :-n] self.append(s) return self diff --git a/test/flagger/test_history.py b/test/flagger/test_history.py index f4c068ef707c7cb2d39b6500e1cd9ed60fe38f7c..59261b5f54bb0cb210aee78c8dab3f737492aad2 100644 --- a/test/flagger/test_history.py +++ b/test/flagger/test_history.py @@ -234,7 +234,7 @@ def test_squeeze(): # checks - for n in range(len(orig)): + for n in range(len(orig) + 1): hist = orig.copy() hist.squeeze(n)