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
da6b8c0d
Commit
da6b8c0d
authored
5 years ago
by
David Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
renamed flag accessors
parent
c53554d2
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/flagger/baseflagger.py
+28
-3
28 additions, 3 deletions
saqc/flagger/baseflagger.py
saqc/flagger/dmpflagger.py
+1
-1
1 addition, 1 deletion
saqc/flagger/dmpflagger.py
test/flagger/test_dmpflagger.py
+3
-3
3 additions, 3 deletions
test/flagger/test_dmpflagger.py
with
32 additions
and
7 deletions
saqc/flagger/baseflagger.py
+
28
−
3
View file @
da6b8c0d
...
...
@@ -11,18 +11,26 @@ from ..lib.types import PandasLike, ArrayLike, T
class
Flags
(
pd
.
CategoricalDtype
):
def
__init__
(
self
,
flags
):
# NOTE: all flag schemes need to support
# at least 3 flag categories:
# * unflagged
# * good
# * bad
assert
len
(
flags
)
>
2
super
().
__init__
(
flags
,
ordered
=
True
)
def
unflagged
(
self
):
return
self
[
0
]
def
min
(
self
):
def
good
(
self
):
return
self
[
1
]
def
max
(
self
):
def
bad
(
self
):
return
self
[
-
1
]
def
suspicious
(
self
):
return
self
[
2
:
-
1
]
def
__getitem__
(
self
,
idx
):
return
self
.
categories
[
idx
]
...
...
@@ -35,7 +43,8 @@ class BaseFlagger:
flags
:
PandasLike
,
flag
:
Optional
[
T
]
=
None
,
**
kwargs
:
Any
)
->
np
.
ndarray
:
flag
=
self
.
flags
.
max
()
if
flag
is
None
else
self
.
_checkFlag
(
flag
)
flag
=
self
.
BAD
if
flag
is
None
else
self
.
_checkFlag
(
flag
)
flags
=
flags
.
copy
()
# NOTE:
# conversion of 'flags' frame to np.array is done here already,
...
...
@@ -48,6 +57,22 @@ class BaseFlagger:
return
flags
@property
def
UNFLAGGED
(
self
):
return
self
.
flags
.
unflagged
()
@property
def
GOOD
(
self
):
return
self
.
flags
.
good
()
@property
def
BAD
(
self
):
return
self
.
flags
.
bad
()
@property
def
SUSPICIOUS
(
self
):
return
self
.
flags
.
suspicious
()
def
initFlags
(
self
,
data
:
pd
.
DataFrame
)
->
pd
.
DataFrame
:
if
isinstance
(
data
,
pd
.
Series
):
out
=
pd
.
Series
(
data
=
self
.
flags
[
0
],
index
=
data
.
index
,
name
=
data
.
name
)
...
...
This diff is collapsed.
Click to expand it.
saqc/flagger/dmpflagger.py
+
1
−
1
View file @
da6b8c0d
...
...
@@ -54,7 +54,7 @@ class DmpFlagger(BaseFlagger):
if
not
isinstance
(
flags
,
pd
.
DataFrame
):
raise
TypeError
flag
=
self
.
flags
.
max
()
if
flag
is
None
else
self
.
_checkFlag
(
flag
)
flag
=
self
.
BAD
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.
test/flagger/test_dmpflagger.py
+
3
−
3
View file @
da6b8c0d
...
...
@@ -32,7 +32,7 @@ def test_basic():
(
var1
,
FlagFields
.
COMMENT
)]
pflags21
=
pflags
.
loc
[
col2
>
var2mean
,
(
var2
,
FlagFields
.
CAUSE
)]
assert
(
pflags11
>
flagger
.
flags
.
min
()
).
all
()
assert
(
pflags11
>
flagger
.
GOOD
).
all
()
assert
(
pflags12
==
"
saqc
"
).
all
()
assert
(
pflags21
==
"
error
"
).
all
()
...
...
@@ -43,8 +43,8 @@ def test_flagOrder():
var
,
*
_
=
data
.
columns
flagger
=
DmpFlagger
()
fmin
=
flagger
.
flags
.
min
()
fmax
=
flagger
.
flags
.
max
()
fmin
=
flagger
.
GOOD
fmax
=
flagger
.
BAD
metastring
=
f
"""
{
Fields
.
VARNAME
}
,Flag
...
...
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