flagOffset fails with `thresh=0`
flagOffset fails for the follwing example:
import pandas as pd
from saqc import SaQC
data = pd.DataFrame({'data':[1,2,3]}, index=pd.date_range('2000','2002', periods=3))
qc = SaQC(data=data)
qc.flagOffset("data", thresh=0, tolerance=1, window=1)
with the following Exception (click to unfold)
Traceback (most recent call last):
File "/home/schaefed/SourceCode/Python/saqc/test.py", line 76, in <module>
qc.flagOffset("data", thresh=0, tolerance=1, window=1)
File "/home/schaefed/SourceCode/Python/saqc/saqc/core/modules/outliers.py", line 87, in flagOffset
return self._defer("flagOffset", locals())
File "/home/schaefed/SourceCode/Python/saqc/saqc/core/modules/__init__.py", line 50, in _defer
return self._wrap(FUNC_MAP[fname])(**flocals, **fkwargs)
File "/home/schaefed/SourceCode/Python/saqc/saqc/core/core.py", line 233, in inner
out = out._callFunction(func, *args, **fkwargs)
File "/home/schaefed/SourceCode/Python/saqc/saqc/core/core.py", line 247, in _callFunction
res = function(data=self._data, flags=self._flags, field=field, *args, **kwargs)
File "/home/schaefed/SourceCode/Python/saqc/saqc/core/register.py", line 160, in __call__
data, flags = self.func(*args, **kwargs)
File "/home/schaefed/SourceCode/Python/saqc/saqc/funcs/outliers.py", line 974, in flagOffset
post_jumps = post_jumps[post_jumps]
UnboundLocalError: local variable 'post_jumps' referenced before assignment
The problem seems to be the check against thresh. Making the calculation of post_jumps unconditional fixes the problem for my use case, but maybe we should rather make thresh an Optional parameter and check against None (e.g. if thresh is not None). What do you think @luenensc ?