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
bcf1a6b3
Commit
bcf1a6b3
authored
3 years ago
by
David Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] bring translation to config workflow
parent
c299afed
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
saqc/core/core.py
+12
-2
12 additions, 2 deletions
saqc/core/core.py
saqc/core/reader.py
+10
-5
10 additions, 5 deletions
saqc/core/reader.py
saqc/core/translator/positionaltranslator.py
+2
-0
2 additions, 0 deletions
saqc/core/translator/positionaltranslator.py
with
24 additions
and
7 deletions
saqc/core/core.py
+
12
−
2
View file @
bcf1a6b3
...
...
@@ -219,7 +219,9 @@ class SaQC(FuncModules):
from
saqc.core.reader
import
readConfig
out
=
stdcopy
.
deepcopy
(
self
)
out
.
_planned
.
extend
(
readConfig
(
fname
,
self
.
_data
,
self
.
_nodata
))
out
.
_planned
.
extend
(
readConfig
(
fname
,
self
.
_translator
,
self
.
_data
,
self
.
_nodata
)
)
if
self
.
_lazy
:
return
out
return
out
.
evaluate
()
...
...
@@ -297,9 +299,17 @@ class SaQC(FuncModules):
out
=
self
if
inplace
else
self
.
copy
(
deep
=
True
)
control
=
APIController
()
# NOTE:
# changes here are likely to be necessary in
# `saqc.core.reader._parseConfig` as well
partial
=
func
.
bind
(
*
fargs
,
**
{
"
nodata
"
:
self
.
_nodata
,
"
flag
"
:
self
.
_translator
(
flag
),
**
fkwargs
},
**
{
"
nodata
"
:
self
.
_nodata
,
"
flag
"
:
self
.
_translator
(
flag
),
"
to_mask
"
:
self
.
_translator
.
TO_MASK
,
**
fkwargs
,
},
)
# expand regular expressions
...
...
This diff is collapsed.
Click to expand it.
saqc/core/reader.py
+
10
−
5
View file @
bcf1a6b3
...
...
@@ -56,7 +56,7 @@ def _injectOptionalColumns(df):
return
df
def
_parseConfig
(
df
,
data
,
nodata
):
def
_parseConfig
(
df
,
translator
,
data
,
nodata
):
funcs
=
[]
for
lineno
,
(
_
,
target
,
expr
)
in
enumerate
(
df
.
itertuples
()):
if
target
==
"
None
"
or
pd
.
isnull
(
target
)
or
pd
.
isnull
(
expr
):
...
...
@@ -72,7 +72,12 @@ def _parseConfig(df, data, nodata):
control
=
ConfigController
(
lineno
=
lineno
+
2
,
expression
=
expr
)
f
=
func
.
bind
(
**
{
"
nodata
"
:
nodata
,
**
kwargs
})
if
"
flag
"
in
kwargs
:
kwargs
[
"
flag
"
]
=
translator
(
kwargs
[
"
flag
"
])
partial
=
func
.
bind
(
**
{
"
nodata
"
:
nodata
,
"
to_mask
"
:
translator
.
TO_MASK
,
**
kwargs
}
)
targets
=
toSequence
(
target
)
...
...
@@ -81,12 +86,12 @@ def _parseConfig(df, data, nodata):
field
=
kwargs
.
get
(
"
field
"
,
target
),
target
=
target
,
)
funcs
.
append
((
selector
,
control
,
f
))
funcs
.
append
((
selector
,
control
,
partial
))
return
funcs
def
readConfig
(
fname
,
data
,
nodata
):
def
readConfig
(
fname
,
translator
,
data
,
nodata
):
df
=
pd
.
read_csv
(
fname
,
sep
=
r
"
\s*;\s*
"
,
...
...
@@ -102,4 +107,4 @@ def readConfig(fname, data, nodata):
df
[
F
.
VARNAME
]
=
df
[
F
.
VARNAME
].
replace
(
r
"
^\s*$
"
,
np
.
nan
,
regex
=
True
)
df
[
F
.
TEST
]
=
df
[
F
.
TEST
].
replace
(
r
"
^\s*$
"
,
np
.
nan
,
regex
=
True
)
return
_parseConfig
(
df
,
data
,
nodata
)
return
_parseConfig
(
df
,
translator
,
data
,
nodata
)
This diff is collapsed.
Click to expand it.
saqc/core/translator/positionaltranslator.py
+
2
−
0
View file @
bcf1a6b3
...
...
@@ -26,6 +26,8 @@ class PositionalTranslator(Translator):
Implements the translation from and to the flagging scheme implemented by CHS
"""
TO_MASK
=
DOUBTFUL
_FORWARD
:
ForwardMap
=
{
0
:
UNFLAGGED
,
1
:
DOUBTFUL
,
2
:
BAD
}
_BACKWARD
:
BackwardMap
=
{
UNTOUCHED
:
0
,
...
...
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