Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SaQC
Manage
Activity
Members
Labels
Plan
Issues
35
Issue boards
Milestones
Wiki
Code
Merge requests
8
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rdm-software
SaQC
Commits
7d958897
Commit
7d958897
authored
3 years ago
by
David Schäfer
Committed by
Bert Palm
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Dismiss the clearance of flags between function calls
parent
c51d48f1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!295
Dismiss the clearance of flags between function calls
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
saqc/core/register.py
+21
-40
21 additions, 40 deletions
saqc/core/register.py
with
21 additions
and
40 deletions
saqc/core/register.py
+
21
−
40
View file @
7d958897
...
...
@@ -145,10 +145,7 @@ def _preCall(
mask
=
mask
,
)
# handle flags - clearing
prepped_flags
=
_prepareFlags
(
flags
,
masking
)
args
=
masked_data
,
field
,
prepped_flags
,
*
args
args
=
masked_data
,
field
,
flags
.
copy
(),
*
args
return
args
,
kwargs
,
state
...
...
@@ -293,23 +290,6 @@ def _isflagged(
return
flagscol
>=
thresh
def
_prepareFlags
(
flags
:
Flags
,
masking
)
->
Flags
:
"""
Prepare flags before each call. Always returns a copy.
Currently this only clears the flags, but in future,
this should be sliced the flags to the columns, that
the saqc-function needs.
Always return a copy of flags or a new flags-frame.
"""
# Either the index or the columns itself changed
if
masking
==
"
none
"
:
return
flags
.
copy
()
return
initFlagsLike
(
flags
)
def
_restoreFlags
(
flags
:
Flags
,
old_state
:
CallState
):
"""
Generate flags from the temporary result-flags and the original flags.
...
...
@@ -361,31 +341,32 @@ def _restoreFlags(flags: Flags, old_state: CallState):
else
:
# field
columns
=
pd
.
Index
([
old_state
.
field
])
for
c
in
columns
.
union
(
new_columns
):
for
col
in
columns
.
union
(
new_columns
):
if
col
not
in
out
:
# ensure existence
out
.
history
[
col
]
=
History
(
index
=
flags
.
history
[
col
].
index
)
old_history
=
out
.
history
[
col
]
new_history
=
flags
.
history
[
col
]
if
c
in
new_columns
:
history
=
flags
.
history
[
c
]
out
.
history
[
c
]
=
History
(
index
=
history
.
index
)
# ensure existence
# new columns were appended to the old history, but we want to have the new
# columns only. If old and new are the same (nothing was appended), we end up
# having a empty history and that is handled later correctly
elif
old_state
.
masking
==
"
none
"
:
sl
=
slice
(
len
(
old_state
.
flags
.
history
[
c
].
columns
),
None
)
history
=
_sliceHistory
(
flags
.
history
[
c
],
sl
)
else
:
history
=
flags
.
history
[
c
]
# We only want to add new columns, that were appended during the last function
# call. If no such columns exist, we end up with an empty new_history.
start
=
0
if
col
in
old_history
.
columns
:
start
=
len
(
old_history
.
columns
)
new_history
=
_sliceHistory
(
new_history
,
slice
(
start
,
None
))
# NOTE:
#
n
othing to update -> i.e. a function did not set any flags at all
#
t
his has implications for function writers: early returns out of
# functions before `flags.__getitem__` was called
at least
once make
,
#
the
function call invisable to the flags/history machinery and
might
#
N
othing to update -> i.e. a function did not set any flags at all
.
#
T
his has implications for function writers: early returns out of
# functions before `flags.__getitem__` was called once
,
make
the
# function call invisable to the flags/history machinery and
likely
# break translation schemes such as the `PositionalTranslator`
if
history
.
empty
:
if
new_
history
.
empty
:
continue
squeezed
=
history
.
max
(
raw
=
True
)
out
.
history
[
c
]
=
out
.
history
[
c
].
append
(
squeezed
,
meta
=
meta
)
squeezed
=
new_
history
.
max
(
raw
=
True
)
out
.
history
[
c
ol
]
=
out
.
history
[
c
ol
].
append
(
squeezed
,
meta
=
meta
)
return
out
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment