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
1ce57072
Commit
1ce57072
authored
6 years ago
by
David Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
added generic isflagged
parent
fe66a4b1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dsl/evaluator.py
+5
-2
5 additions, 2 deletions
dsl/evaluator.py
test/test_generic.py
+20
-0
20 additions, 0 deletions
test/test_generic.py
with
25 additions
and
2 deletions
dsl/evaluator.py
+
5
−
2
View file @
1ce57072
...
...
@@ -9,6 +9,8 @@ from numbers import Number
import
numpy
as
np
import
pandas
as
pd
from
flagger
import
BaseFlagger
# supported operators
OPERATORS
=
{
...
...
@@ -24,7 +26,6 @@ OPERATORS = {
}
def
initFunctionNamespace
(
nodata
):
def
initFunctionNamespace
(
nodata
,
flagger
):
return
{
"
abs
"
:
(
abs
,
"
data
"
),
...
...
@@ -34,7 +35,9 @@ def initFunctionNamespace(nodata, flagger):
"
sum
"
:
(
np
.
sum
,
"
data
"
),
"
std
"
:
(
np
.
std
,
"
data
"
),
"
len
"
:
(
len
,
"
data
"
),
"
ismissing
"
:
(
lambda
d
:
((
d
==
nodata
)
|
pd
.
isnull
(
d
)),
"
data
"
)}
"
ismissing
"
:
(
lambda
d
:
((
d
==
nodata
)
|
pd
.
isnull
(
d
)),
"
data
"
),
"
isflagged
"
:
(
flagger
.
isFlagged
,
"
flags
"
)
}
def
setKey
(
d
,
key
,
value
):
...
...
This diff is collapsed.
Click to expand it.
test/test_generic.py
+
20
−
0
View file @
1ce57072
...
...
@@ -34,5 +34,25 @@ def test_ismissing():
assert
(
pd
.
isnull
(
fdata
)
|
(
fdata
==
nodata
)).
all
()
def
test_isflagged
():
flagger
=
SimpleFlagger
()
data
=
initData
()
flags
=
flagger
.
emptyFlags
(
data
,
0
)
var1
,
var2
,
*
_
=
data
.
columns
flags
.
iloc
[::
2
,
0
]
=
flagger
.
setFlag
(
flags
.
iloc
[::
2
,
0
])
idx
=
evalCondition
(
"
isflagged({:})
"
.
format
(
var1
),
flagger
,
data
,
flags
,
var2
)
flagged
=
flagger
.
isFlagged
(
flags
[
var1
])
assert
(
flagged
==
idx
).
all
if
__name__
==
"
__main__
"
:
test_ismissing
()
test_isflagged
()
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