Skip to content

Check validity of CustomRoller Input

David Schäfer requested to merge roller-check into develop

Without the proposed change, the following code:

import pandas as pd
from saqc import SaQC

df = pd.DataFrame(
    data={"x": [0, 0, 0, 0, 0, 1]},
    index=["2022-01-01 00:00", "2022-01-01 00:10", "2022-01-01 00:20", "2022-01-01 00:30", "2022-01-01 00:40", "2022-01-01 00:50"]
)
qc = SaQC(data=df)
qc = qc.flagConstants(field="x", window="10min", thresh=0)

leads to:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/schaefed/SourceCode/Python/saqc/saqc/core/register.py", line 386, in inner
    out = func(out, **kwargs)
  File "/home/schaefed/SourceCode/Python/saqc/saqc/funcs/constants.py", line 80, in flagConstants
    rolling = customRoller(d, **kws)
  File "/home/schaefed/SourceCode/Python/saqc/saqc/lib/rolling.py", line 196, in __init__
    verified = obj.rolling(
  File "/home/schaefed/SourceCode/Python/saqc/venv/lib/python3.10/site-packages/pandas/core/generic.py", line 10868, in rolling
    return Rolling(
  File "/home/schaefed/SourceCode/Python/saqc/venv/lib/python3.10/site-packages/pandas/core/window/rolling.py", line 158, in __init__
    self.validate()
  File "/home/schaefed/SourceCode/Python/saqc/venv/lib/python3.10/site-packages/pandas/core/window/rolling.py", line 1532, in validate
    raise ValueError("window must be an integer 0 or greater")
ValueError: window must be an integer 0 or greater

which is missleading.

Merge request reports

Loading