Skip to content
Snippets Groups Projects
Commit 955a8b73 authored by Peter Lünenschloß's avatar Peter Lünenschloß
Browse files

added date-like check/removed test with list input

parent a69778a0
No related branches found
No related tags found
8 merge requests!685Release 2.4,!684Release 2.4,!567Release 2.2.1,!566Release 2.2,!501Release 2.1,!372fix doctest snippets,!369Current documentation,!318Included new input format in flag Manual
Pipeline #46276 passed with stage
in 3 minutes and 21 seconds
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
from typing import Any, Tuple, Union from typing import Any, Tuple, Union
from typing_extensions import Literal from typing_extensions import Literal
import pandas as pd import pandas as pd
from dateutil.parser import ParserError
import numpy as np
from dios import DictOfSeries from dios import DictOfSeries
from saqc.constants import BAD, UNFLAGGED from saqc.constants import BAD, UNFLAGGED
...@@ -246,9 +248,19 @@ def flagManual( ...@@ -246,9 +248,19 @@ def flagManual(
raise ValueError("mdata has no index") raise ValueError("mdata has no index")
# check, if intervals where passed in format (index:start-time, data:end-time) # check, if intervals where passed in format (index:start-time, data:end-time)
if isinstance(mdata.iloc[0], (pd.Timestamp, str)): try:
pd.to_datetime(mdata)
except ParserError:
dtlike = False
else:
if mdata.astype(str).map(str.isnumeric).any():
dtlike = False
else:
dtlike = True
if dtlike:
mdata = pd.Series( mdata = pd.Series(
0, index=mdata.index.join(pd.DatetimeIndex(mdata), how="outer") np.nan, index=mdata.index.join(pd.DatetimeIndex(mdata), how="outer")
) )
mdata[::2] = mflag mdata[::2] = mflag
......
...@@ -202,7 +202,7 @@ def test_flagManual(data, field): ...@@ -202,7 +202,7 @@ def test_flagManual(data, field):
kwargs_list = [ kwargs_list = [
dict(mdata=mdata, mflag="a", method="plain", flag=BAD), dict(mdata=mdata, mflag="a", method="plain", flag=BAD),
dict(mdata=mdata.to_list(), mflag="a", method="plain", flag=BAD), # dict(mdata=mdata.to_list(), mflag="a", method="plain", flag=BAD),
dict(mdata=mdata, mflag="a", method="ontime", flag=BAD), dict(mdata=mdata, mflag="a", method="ontime", flag=BAD),
dict(mdata=shrinked, mflag="a", method="ontime", flag=BAD), dict(mdata=shrinked, mflag="a", method="ontime", flag=BAD),
] ]
......
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