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
e9aa9d74
Commit
e9aa9d74
authored
11 months ago
by
David Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
internal renamings
parent
fdb5361f
No related branches found
No related tags found
2 merge requests
!842
Annotated float scheme
,
!827
Represent all flags by DictOfSeries
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
saqc/core/translation/dmpscheme.py
+19
-13
19 additions, 13 deletions
saqc/core/translation/dmpscheme.py
with
19 additions
and
13 deletions
saqc/core/translation/dmpscheme.py
+
19
−
13
View file @
e9aa9d74
...
@@ -69,29 +69,29 @@ class DmpScheme(MappingScheme):
...
@@ -69,29 +69,29 @@ class DmpScheme(MappingScheme):
def
__init__
(
self
):
def
__init__
(
self
):
super
().
__init__
(
forward
=
self
.
_FORWARD
,
backward
=
self
.
_BACKWARD
)
super
().
__init__
(
forward
=
self
.
_FORWARD
,
backward
=
self
.
_BACKWARD
)
def
toHistory
(
self
,
field_
flags
:
pd
.
DataFrame
):
def
toHistory
(
self
,
flags
:
pd
.
DataFrame
):
"""
"""
Translate a single field of external ``Flags`` to a ``History``
Translate a single field of external ``Flags`` to a ``History``
"""
"""
field_
history
=
History
(
field_
flags
.
index
)
history
=
History
(
flags
.
index
)
for
(
flag
,
cause
,
comment
),
values
in
field_
flags
.
groupby
(
_QUALITY_LABELS
):
for
(
flag
,
cause
,
comment
),
values
in
flags
.
groupby
(
_QUALITY_LABELS
):
try
:
try
:
comment
=
json
.
loads
(
comment
)
comment
=
json
.
loads
(
comment
)
except
json
.
decoder
.
JSONDecodeError
:
except
json
.
decoder
.
JSONDecodeError
:
comment
=
{
"
test
"
:
"
unknown
"
,
"
comment
"
:
""
}
comment
=
{
"
test
"
:
"
unknown
"
,
"
comment
"
:
""
}
hist
col
=
pd
.
Series
(
np
.
nan
,
index
=
field_
flags
.
index
)
col
umn
=
pd
.
Series
(
np
.
nan
,
index
=
flags
.
index
)
hist
col
.
loc
[
values
.
index
]
=
self
(
flag
)
col
umn
.
loc
[
values
.
index
]
=
self
(
flag
)
meta
=
{
meta
=
{
"
func
"
:
comment
[
"
test
"
],
"
func
"
:
comment
[
"
test
"
],
"
kwargs
"
:
{
"
comment
"
:
comment
[
"
comment
"
],
"
cause
"
:
cause
},
"
kwargs
"
:
{
"
comment
"
:
comment
[
"
comment
"
],
"
cause
"
:
cause
},
}
}
field_
history
.
append
(
hist
col
,
meta
=
meta
)
history
.
append
(
col
umn
,
meta
=
meta
)
return
field_
history
return
history
def
toInternal
(
self
,
d
f
:
pd
.
DataFrame
)
->
Flags
:
def
toInternal
(
self
,
f
lags
:
pd
.
DataFrame
|
DictOfSeries
)
->
Flags
:
"""
"""
Translate from
'
external flags
'
to
'
internal flags
'
Translate from
'
external flags
'
to
'
internal flags
'
...
@@ -105,12 +105,18 @@ class DmpScheme(MappingScheme):
...
@@ -105,12 +105,18 @@ class DmpScheme(MappingScheme):
Flags object
Flags object
"""
"""
self
.
validityCheck
(
d
f
)
self
.
validityCheck
(
f
lags
)
data
=
{}
data
=
{}
for
field
in
df
.
columns
.
get_level_values
(
0
).
drop_duplicates
():
if
isinstance
(
flags
,
pd
.
DataFrame
):
data
[
str
(
field
)]
=
self
.
toHistory
(
df
[
field
])
fields
=
flags
.
columns
.
get_level_values
(
0
).
drop_duplicates
()
else
:
fields
=
flags
.
columns
for
field
in
fields
:
data
[
str
(
field
)]
=
self
.
toHistory
(
flags
[
field
])
return
Flags
(
data
)
return
Flags
(
data
)
...
@@ -167,7 +173,7 @@ class DmpScheme(MappingScheme):
...
@@ -167,7 +173,7 @@ class DmpScheme(MappingScheme):
return
out
return
out
@classmethod
@classmethod
def
validityCheck
(
cls
,
dios
:
DictOfSeries
)
->
None
:
def
validityCheck
(
cls
,
flags
:
pd
.
DataFrame
|
DictOfSeries
)
->
None
:
"""
"""
Check wether the given causes and comments are valid.
Check wether the given causes and comments are valid.
...
@@ -176,7 +182,7 @@ class DmpScheme(MappingScheme):
...
@@ -176,7 +182,7 @@ class DmpScheme(MappingScheme):
df : external flags
df : external flags
"""
"""
for
df
in
dio
s
.
values
():
for
df
in
flag
s
.
values
():
if
not
df
.
columns
.
isin
(
_QUALITY_LABELS
).
all
(
axis
=
None
):
if
not
df
.
columns
.
isin
(
_QUALITY_LABELS
).
all
(
axis
=
None
):
raise
TypeError
(
raise
TypeError
(
...
...
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