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
dbdade94
Commit
dbdade94
authored
5 years ago
by
David Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
various modifactions
parent
abc75bd0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
saqc/flagger/baseflagger.py
+16
-13
16 additions, 13 deletions
saqc/flagger/baseflagger.py
saqc/flagger/dmpflagger.py
+4
-6
4 additions, 6 deletions
saqc/flagger/dmpflagger.py
with
20 additions
and
19 deletions
saqc/flagger/baseflagger.py
+
16
−
13
View file @
dbdade94
...
...
@@ -41,14 +41,14 @@ class BaseFlagger:
pandas data structures tend to behave unpredictively
in assignments, especially if a multi column index is used
"""
if
flag
is
None
:
flag
=
self
.
flags
.
max
()
else
:
self
.
_checkFlag
(
flag
)
flag
=
self
.
flags
.
max
()
if
flag
is
None
else
self
.
_checkFlag
(
flag
)
flags
=
flags
.
copy
()
# NOTE: conversion of "flags frame to np.array is done here already, since return argument is just the array
# anyway. For applying mulitdimensional indexing on the DataFrame "flags", you would have to stack it first,
# with .stack() (try flags.stack[flags<flag] = flag and than unstack.)
# NOTE:
# conversion of 'flags' frame to np.array is done here already,
# since return argument is just the array anyway. For applying
# mulitdimensional indexing on the DataFrame 'flags', you would
# have to stack it first
# (try flags.stack[flags<flag] = flag and than unstack.)
flags
=
flags
.
values
flags
[
flags
<
flag
]
=
flag
...
...
@@ -57,20 +57,23 @@ class BaseFlagger:
def
initFlags
(
self
,
data
:
pd
.
DataFrame
)
->
pd
.
DataFrame
:
out
=
data
.
copy
()
out
[:]
=
self
.
flags
[
0
]
# astype conversion of return Dataframe performed seperately, because pd.DataFrame(...,dtype=self.flags)
# wont give you categorical flag objects:
# NOTE:
# astype conversion of return Dataframe performed
# seperately, because pd.DataFrame(..., dtype=self.flags)
# wont give you categorical flag objects
return
out
.
astype
(
self
.
flags
)
def
isFlagged
(
self
,
flags
:
ArrayLike
,
flag
:
T
=
None
)
->
ArrayLike
:
if
flag
is
None
:
return
pd
.
notnull
(
flags
)
&
(
flags
>
self
.
flags
[
0
])
self
.
_checkFlag
(
flag
)
return
flags
==
flag
return
flags
==
self
.
_checkFlag
(
flag
)
def
_checkFlag
(
self
,
flag
):
if
flag
not
in
self
.
flags
:
raise
ValueError
(
f
"
Invalid flag
'
{
flag
}
'
.
"
f
"
Possible choices are
{
list
(
self
.
flags
.
categories
)[
1
:
]
}
"
)
raise
ValueError
(
f
"
Invalid flag
'
{
flag
}
'
.
"
f
"
Possible choices are
{
list
(
self
.
flags
.
categories
)[
1
:
]
}
"
)
return
flag
def
nextTest
(
self
):
pass
This diff is collapsed.
Click to expand it.
saqc/flagger/dmpflagger.py
+
4
−
6
View file @
dbdade94
...
...
@@ -36,10 +36,11 @@ class DmpFlagger(BaseFlagger):
self
.
project_version
=
version
.
decode
().
strip
()
def
initFlags
(
self
,
data
,
**
kwargs
):
columns
=
data
.
columns
if
isinstance
(
data
,
pd
.
DataFrame
)
else
[
data
.
name
]
if
isinstance
(
data
,
pd
.
Series
):
data
=
data
.
to_frame
()
colindex
=
pd
.
MultiIndex
.
from_product
(
[
columns
,
self
.
flag_fields
],
[
data
.
columns
,
self
.
flag_fields
],
names
=
[
ColumnLevels
.
VARIABLES
,
ColumnLevels
.
FLAGS
])
out
=
pd
.
DataFrame
(
data
=
self
.
flags
[
0
],
...
...
@@ -53,10 +54,7 @@ class DmpFlagger(BaseFlagger):
if
not
isinstance
(
flags
,
pd
.
DataFrame
):
raise
TypeError
if
flag
is
None
:
flag
=
self
.
flags
.
max
()
else
:
self
.
_checkFlag
(
flag
)
flag
=
self
.
flags
.
max
()
if
flag
is
None
else
self
.
_checkFlag
(
flag
)
if
Keywords
.
VERSION
in
comment
:
comment
=
comment
.
replace
(
Keywords
.
VERSION
,
self
.
project_version
)
...
...
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