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

[FIX] breaks.flagIsolated was only flaggin nan values

parent 9d51a067
No related branches found
No related tags found
2 merge requests!271Static expansion of regular expressions,!260Follow-Up Translations
Pipeline #24679 failed with stage
in 1 minute and 56 seconds
This commit is part of merge request !260. Comments created here will be created in the context of that merge request.
...@@ -126,16 +126,21 @@ def flagIsolated( ...@@ -126,16 +126,21 @@ def flagIsolated(
bools = pd.Series(data=0, index=mask.index, dtype=bool) bools = pd.Series(data=0, index=mask.index, dtype=bool)
for srs in groupConsecutives(mask): for srs in groupConsecutives(mask):
if np.all(~srs): if np.all(~srs):
# we found a chunk of non-nan values
start = srs.index[0] start = srs.index[0]
stop = srs.index[-1] stop = srs.index[-1]
if stop - start <= group_window: if stop - start <= group_window:
# the chunk is large enough
left = mask[start - gap_window : start].iloc[:-1] left = mask[start - gap_window : start].iloc[:-1]
if left.all(): if left.all():
# the section before our chunk is nan-only
right = mask[stop : stop + gap_window].iloc[1:] right = mask[stop : stop + gap_window].iloc[1:]
if right.all(): if right.all():
# the section after our chunk is nan-only
# -> we found a chunk of isolated non-values
bools[start:stop] = True bools[start:stop] = True
flags[mask, field] = flag flags[bools, 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