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

bugfix: unmasking reinjected the new (i.e. nan) instead of the old values...

bugfix: unmasking reinjected the new (i.e. nan) instead of the old values (this should have been caught by a test)
parent ec820804
No related branches found
No related tags found
2 merge requests!193Release 1.4,!188Release 1.4
Pipeline #7649 passed with stages
in 12 minutes and 35 seconds
...@@ -219,14 +219,7 @@ class SaQC: ...@@ -219,14 +219,7 @@ class SaQC:
def inner(field: str, *args, regex: bool = False, to_mask=None, plot=False, inplace=False, **kwargs): def inner(field: str, *args, regex: bool = False, to_mask=None, plot=False, inplace=False, **kwargs):
fields = [field] if not regex else self._data.columns[self._data.columns.str.match(field)] fields = [field] if not regex else self._data.columns[self._data.columns.str.match(field)]
if func_name in ("flagGeneric", "procGeneric"): kwargs.setdefault('nodata', self._nodata)
# NOTE:
# We need to pass `nodata` to the generic functions
# (to implement stuff like `ismissing`). As we
# should not interfere with proper nodata attributes
# of other test functions (e.g. `flagMissing`) we
# special case the injection
kwargs.setdefault('nodata', self._nodata)
# to_mask is a control keyword # to_mask is a control keyword
ctrl_kws = { ctrl_kws = {
...@@ -247,10 +240,7 @@ class SaQC: ...@@ -247,10 +240,7 @@ class SaQC:
"ctrl_kws": ctrl_kws, "ctrl_kws": ctrl_kws,
} }
if inplace: out = self if inplace else self.copy()
out = self
else:
out = self.copy()
for field in fields: for field in fields:
dump_copy = {**func_dump, "field": field} dump_copy = {**func_dump, "field": field}
...@@ -331,11 +321,11 @@ def _unmaskData(data_old, mask_old, data_new, flagger_new, to_mask): ...@@ -331,11 +321,11 @@ def _unmaskData(data_old, mask_old, data_new, flagger_new, to_mask):
# TODO: this is heavily undertested # TODO: this is heavily undertested
# NOTE: # NOTE:
# we only need to respect columns, that was masked, # we only need to respect columns, that were masked,
# and also are still present in new data. # and are also still present in new data.
# this throw out: # this throws out:
# - any newly assigned columns # - any newly assigned columns
# - columns that wasn't masked, due to masking-kw # - columns that were excluded from masking
columns = mask_old.dropempty().columns.intersection(data_new.dropempty().columns) columns = mask_old.dropempty().columns.intersection(data_new.dropempty().columns)
mask_new = flagger_new.isFlagged(field=columns, flag=to_mask, comparator="==") mask_new = flagger_new.isFlagged(field=columns, flag=to_mask, comparator="==")
...@@ -351,7 +341,7 @@ def _unmaskData(data_old, mask_old, data_new, flagger_new, to_mask): ...@@ -351,7 +341,7 @@ def _unmaskData(data_old, mask_old, data_new, flagger_new, to_mask):
# reapplying old values on masked positions # reapplying old values on masked positions
if np.any(mask): if np.any(mask):
data = np.where(mask, data_new[col].values, data_old[col].values) data = np.where(mask, data_old[col].values, data_new[col].values)
data_new[col] = pd.Series(data=data, index=is_masked.index) data_new[col] = pd.Series(data=data, index=is_masked.index)
return data_new return data_new
......
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