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
65cd7e30
Commit
65cd7e30
authored
3 years ago
by
David Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] pass actual flags into generic
parent
b3a98afe
No related branches found
No related tags found
3 merge requests
!271
Static expansion of regular expressions
,
!269
Several fixes
,
!260
Follow-Up Translations
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
saqc/core/register.py
+0
-7
0 additions, 7 deletions
saqc/core/register.py
saqc/funcs/generic.py
+18
-15
18 additions, 15 deletions
saqc/funcs/generic.py
with
18 additions
and
22 deletions
saqc/core/register.py
+
0
−
7
View file @
65cd7e30
...
...
@@ -210,13 +210,6 @@ def _getMaskingThresh(masking, kwargs, fname):
if
not
isinstance
(
thresh
,
(
bool
,
float
,
int
)):
raise
TypeError
(
f
"'
to_mask
'
must be of type bool or float
"
)
if
masking
==
"
none
"
and
thresh
not
in
(
False
,
np
.
inf
):
# TODO: fix warning reference to docu
warnings
.
warn
(
f
"
the saqc-function
{
fname
!r}
ignores masking and therefore does not evaluate the passed
"
f
"'
to_mask
'
-keyword. Please refer to the documentation: TODO
"
)
if
thresh
is
True
:
# masking ON
thresh
=
UNFLAGGED
...
...
This diff is collapsed.
Click to expand it.
saqc/funcs/generic.py
+
18
−
15
View file @
65cd7e30
...
...
@@ -10,8 +10,9 @@ import pandas as pd
from
dios
import
DictOfSeries
from
saqc.constants
import
*
from
saqc.core
import
register
,
initFlagsLike
,
Flags
from
saqc.constants
import
GOOD
,
BAD
,
UNFLAGGED
from
saqc.core.flags
import
initFlagsLike
,
Flags
from
saqc.core.register
import
register
,
_maskData
from
saqc.core.visitor
import
ENVIRONMENT
import
operator
as
op
...
...
@@ -84,13 +85,14 @@ def _execGeneric(
return
func
(
*
args
)
@register
(
masking
=
"
all
"
,
module
=
"
generic
"
)
@register
(
masking
=
"
none
"
,
module
=
"
generic
"
)
def
process
(
data
:
DictOfSeries
,
field
:
str
,
flags
:
Flags
,
func
:
Callable
[[
pd
.
Series
],
pd
.
Series
],
nodata
:
float
=
np
.
nan
,
to_mask
:
float
=
UNFLAGGED
,
**
kwargs
,
)
->
Tuple
[
DictOfSeries
,
Flags
]:
"""
...
...
@@ -142,18 +144,20 @@ def process(
>>>
lambda
temperature
,
uncertainty
:
np
.
round
(
temperature
)
*
np
.
sqrt
(
uncertainty
)
"""
data
[
field
]
=
_execGeneric
(
flags
,
data
,
func
,
field
,
nodata
).
squeeze
()
# we get the data unmaskes in order to also receive flags,
# so let's ge to the masking manually
data_masked
,
_
=
_maskData
(
data
,
flags
,
data
.
columns
,
to_mask
)
data
[
field
]
=
_execGeneric
(
flags
,
data_masked
,
func
,
field
,
nodata
).
squeeze
()
# TODO: the former comment wished to overwrite the column, but i'm not sure -- palmb
# see #GL177
if
field
in
flags
:
flags
.
drop
(
field
)
flags
[
field
]
=
initFlagsLike
(
data
[
field
])[
field
]
return
data
,
flags
@register
(
masking
=
"
all
"
,
module
=
"
generic
"
)
@register
(
masking
=
"
none
"
,
module
=
"
generic
"
)
def
flag
(
data
:
DictOfSeries
,
field
:
str
,
...
...
@@ -161,6 +165,7 @@ def flag(
func
:
Callable
[[
pd
.
Series
],
pd
.
Series
],
nodata
:
float
=
np
.
nan
,
flag
:
float
=
BAD
,
to_mask
:
float
=
UNFLAGGED
,
**
kwargs
,
)
->
Tuple
[
DictOfSeries
,
Flags
]:
# TODO : fix docstring, check if all still works
...
...
@@ -240,10 +245,11 @@ def flag(
>>>
lambda
level
:
np
.
sqrt
(
level
)
>
7
"""
# NOTE:
# The naming of the func parameter is pretty confusing
# as it actually holds the result of a generic expression
mask
=
_execGeneric
(
flags
,
data
,
func
,
field
,
nodata
).
squeeze
()
# we get the data unmaskes in order to also receive flags,
# so let's ge to the masking manually
data_masked
,
_
=
_maskData
(
data
,
flags
,
data
.
columns
,
to_mask
)
mask
=
_execGeneric
(
flags
,
data_masked
,
func
,
field
,
nodata
).
squeeze
()
if
np
.
isscalar
(
mask
):
raise
TypeError
(
f
"
generic expression does not return an array
"
)
if
not
np
.
issubdtype
(
mask
.
dtype
,
np
.
bool_
):
...
...
@@ -252,9 +258,6 @@ def flag(
if
field
not
in
flags
.
columns
:
flags
[
field
]
=
pd
.
Series
(
UNFLAGGED
,
index
=
mask
.
index
,
name
=
field
)
# if flags.getFlags(field).empty:
# flags = flags.merge(
# flags.initFlags(
# data=pd.Series(name=field, index=mask.index, dtype=np.float64)))
flags
[
mask
,
field
]
=
flag
return
data
,
flags
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