Skip to content
Snippets Groups Projects
Commit 6143c92e authored by David Schäfer's avatar David Schäfer
Browse files

[FIX] excess history column for new variables through generic.flag

parent 5c97a4de
No related branches found
No related tags found
2 merge requests!271Static expansion of regular expressions,!260Follow-Up Translations
Pipeline #24687 passed with stage
in 1 minute and 57 seconds
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
from functools import partial from functools import partial
from inspect import signature from inspect import signature
from typing import Tuple, Any, Union, Callable from typing import Tuple, Union, Callable
import numpy as np import numpy as np
import pandas as pd import pandas as pd
...@@ -144,8 +144,8 @@ def process( ...@@ -144,8 +144,8 @@ def process(
>>> lambda temperature, uncertainty: np.round(temperature) * np.sqrt(uncertainty) >>> lambda temperature, uncertainty: np.round(temperature) * np.sqrt(uncertainty)
""" """
# we get the data unmaskes in order to also receive flags, # we get the data unmasked in order to also receive flags,
# so let's ge to the masking manually # so let's do to the masking manually
data_masked, _ = _maskData(data, flags, data.columns, to_mask) data_masked, _ = _maskData(data, flags, data.columns, to_mask)
data[field] = _execGeneric(flags, data_masked, func, field, nodata).squeeze() data[field] = _execGeneric(flags, data_masked, func, field, nodata).squeeze()
...@@ -245,8 +245,8 @@ def flag( ...@@ -245,8 +245,8 @@ def flag(
>>> lambda level: np.sqrt(level) > 7 >>> lambda level: np.sqrt(level) > 7
""" """
# we get the data unmaskes in order to also receive flags, # we get the data unmasked, in order to also receive flags,
# so let's ge to the masking manually # so let's do to the masking manually
data_masked, _ = _maskData(data, flags, data.columns, to_mask) data_masked, _ = _maskData(data, flags, data.columns, to_mask)
mask = _execGeneric(flags, data_masked, func, field, nodata).squeeze() mask = _execGeneric(flags, data_masked, func, field, nodata).squeeze()
...@@ -255,9 +255,6 @@ def flag( ...@@ -255,9 +255,6 @@ def flag(
if not np.issubdtype(mask.dtype, np.bool_): if not np.issubdtype(mask.dtype, np.bool_):
raise TypeError(f"generic expression does not return a boolean array") raise TypeError(f"generic expression does not return a boolean array")
if field not in flags.columns: flags[field] = mask.replace({False: UNFLAGGED, True: BAD})
flags[field] = pd.Series(UNFLAGGED, index=mask.index, name=field)
flags[mask, field] = flag
return data, flags return data, flags
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