Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SaQC
Manage
Activity
Members
Labels
Plan
Issues
36
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
2abc83bf
Commit
2abc83bf
authored
4 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
simplyfied register, according to
@schaefed
's suggestions
parent
e124ceaa
No related branches found
No related tags found
3 merge requests
!271
Static expansion of regular expressions
,
!260
Follow-Up Translations
,
!237
Flagger Translations
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
saqc/core/register.py
+18
-10
18 additions, 10 deletions
saqc/core/register.py
with
18 additions
and
10 deletions
saqc/core/register.py
+
18
−
10
View file @
2abc83bf
...
...
@@ -102,15 +102,15 @@ def _preCall(func: callable, args: tuple, kwargs: dict, masking: MaskingStrT, fn
data
,
field
,
flagger
,
*
args
=
args
ctrl
=
CallCtrl
(
func
,
data
.
copy
(),
field
,
flagger
.
copy
(),
args
,
kwargs
,
masking
=
masking
,
mthresh
=
mthresh
)
# masking
columns
=
_getMaskingColumns
(
ctrl
,
ctrl
.
masking
)
#
handle data -
masking
columns
=
_getMaskingColumns
(
data
,
field
,
masking
)
data
,
mask
=
_maskData
(
data
,
flagger
,
columns
,
mthresh
)
# store mask
ctrl
.
mask
=
mask
#
flags
flagger
=
_prepareFlags
(
flagger
,
ctrl
)
#
handle flags - clearing
flagger
=
_prepareFlags
(
flagger
,
masking
)
args
=
data
,
field
,
flagger
,
*
args
return
args
,
kwargs
,
ctrl
...
...
@@ -144,18 +144,23 @@ def _postCall(result, ctrl: CallCtrl, fname: str) -> FuncReturnT:
return
data
,
flagger
def
_getMaskingColumns
(
ctrl
:
CallC
tr
l
,
masking
:
MaskingStrT
):
def
_getMaskingColumns
(
data
:
dios
.
DictOfSeries
,
field
:
s
tr
,
masking
:
MaskingStrT
):
"""
Returns
-------
columns: pd.Index
Data columns that need to be masked.
Raises
------
ValueError: if given masking literal is not supported
"""
if
masking
==
'
all
'
:
return
ctrl
.
data
.
columns
return
data
.
columns
if
masking
==
'
none
'
:
return
pd
.
Index
([])
if
masking
==
'
field
'
:
return
pd
.
Index
([
ctrl
.
field
])
return
pd
.
Index
([
field
])
raise
ValueError
(
f
"
wrong use of `register(masking=
{
ctrl
.
masking
}
)`
"
)
...
...
@@ -243,12 +248,12 @@ def _getMask(flags: Union[np.array, pd.Series], thresh: float) -> Union[np.array
return
flags
>=
thresh
def
_prepareFlags
(
flagger
:
Flagger
,
ctrl
:
CallCtrl
)
->
Flagger
:
def
_prepareFlags
(
flagger
:
Flagger
,
masking
)
->
Flagger
:
"""
Clear flags before each call.
"""
#
e
ither the index or the columns itself changed
if
ctrl
.
masking
==
'
none
'
:
#
E
ither the index or the columns itself changed
if
masking
==
'
none
'
:
return
flagger
return
initFlagsLike
(
flagger
,
initial_value
=
UNTOUCHED
)
...
...
@@ -267,6 +272,9 @@ def _restoreFlags(flagger: Flagger, ctrl: CallCtrl):
columns
=
columns
.
append
(
pd
.
Index
([
ctrl
.
field
]))
for
c
in
columns
:
# this implicitly squash the new-flagger history (RHS) to a single column, which than is appended to
# the old history (LHS). The new-flagger history possibly consist of multiple columns, one for each
# time flags was set to the flagger.
result
[
c
]
=
flagger
[
c
]
return
result
...
...
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