Skip to content
Snippets Groups Projects
Commit e8f9fce8 authored by David Schäfer's avatar David Schäfer Committed by Bert Palm
Browse files

reader: fixed the loss of function names through the config interface

parent 78f6dcdd
No related branches found
No related tags found
1 merge request!231new Flagger and Stuff
Pipeline #20631 passed with stages
in 2 minutes and 34 seconds
......@@ -141,7 +141,7 @@ class SaQC(FuncModules):
def readConfig(self, fname):
from saqc.core.reader import readConfig
out = stdcopy.deepcopy(self)
out._to_call.extend(readConfig(fname, self._flags))
out._to_call.extend(readConfig(fname, self._flags, self._nodata))
return out
def _expandFields(self, selector: ColumnSelector, func: SaQCFunction, variables: pd.Index) -> Sequence[Tuple[ColumnSelector, SaQCFunction]]:
......@@ -178,12 +178,10 @@ class SaQC(FuncModules):
data_result, flags_result = _saqcCallFunc(sel, control, func, data, flags)
except Exception as e:
t1 = timeit.default_timer()
logger.debug(f"{func.name} failed after {t1 - t0} sec")
_handleErrors(e, sel.field, control, func, self._error_policy)
continue
else:
t1 = timeit.default_timer()
logger.debug(f"{func.name} finished after {t1 - t0} sec")
if control.plot:
plotHook(
......
......@@ -56,7 +56,7 @@ def _injectOptionalColumns(df):
return df
def _parseConfig(df, flags):
def _parseConfig(df, flags, nodata):
funcs = []
for lineno, (_, target, expr, plot) in enumerate(df.itertuples()):
if target == "None" or pd.isnull(target) or pd.isnull(expr):
......@@ -83,13 +83,13 @@ def _parseConfig(df, flags):
expression=expr
)
f = func.bind(**kwargs)
f = func.bind(**{"nodata": nodata, **kwargs})
funcs.append((selector, control, f))
return funcs
def readConfig(fname, flags):
def readConfig(fname, flags, nodata):
df = pd.read_csv(
fname,
sep=r"\s*;\s*",
......@@ -108,4 +108,4 @@ def readConfig(fname, flags):
df[F.TEST] = df[F.TEST].replace(r"^\s*$", np.nan, regex=True)
df[F.PLOT] = df[F.PLOT].replace({"False": "", EMPTY: "", np.nan: ""})
df = df.astype({F.PLOT: bool})
return _parseConfig(df, flags)
return _parseConfig(df, flags, nodata)
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