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
642b9c17
Commit
642b9c17
authored
6 years ago
by
David Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
pytest
parent
7836db9b
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
test/test_core.py
+6
-18
6 additions, 18 deletions
test/test_core.py
test/test_evaluator.py
+6
-8
6 additions, 8 deletions
test/test_evaluator.py
test/testfuncs.py
+0
-12
0 additions, 12 deletions
test/testfuncs.py
with
12 additions
and
38 deletions
test/test_core.py
+
6
−
18
View file @
642b9c17
...
...
@@ -7,18 +7,7 @@ import pandas as pd
from
core
import
flaggingRunner
from
config
import
Fields
from
flagger
import
AbstractFlagger
from
.testfuncs
import
initData
,
initEmptyFlags
,
printFailed
,
printSuccess
class
TestFlagger
(
AbstractFlagger
):
@property
def
no_flag
(
self
):
return
0
@property
def
critical_flag
(
self
):
return
2
from
.testfuncs
import
initData
def
initMeta
(
data
):
...
...
@@ -37,19 +26,18 @@ def initMeta(data):
def
testTemporalPartitioning
():
data
=
initData
()
flags
=
initEmptyFlags
(
data
)
meta
=
initMeta
(
data
)
flagger
=
Tes
tFlagger
()
pdata
,
pflags
=
flaggingRunner
(
meta
,
data
,
flags
,
flagger
)
flagger
=
Abstrac
tFlagger
(
0
,
1
)
pdata
,
pflags
=
flaggingRunner
(
meta
,
flagger
,
data
)
fields
=
[
Fields
.
VARNAME
,
Fields
.
STARTDATE
,
Fields
.
ENDDATE
]
for
_
,
row
in
meta
.
iterrows
():
vname
,
start_date
,
end_date
=
row
[
fields
]
fchunk
=
pflags
[
vname
].
dropna
()
assert
fchunk
.
index
.
min
()
==
start_date
,
printFailed
(
"
equal start dates
"
)
assert
fchunk
.
index
.
max
()
==
end_date
,
printFailed
(
"
equal end dates
"
)
printSuccess
()
assert
fchunk
.
index
.
min
()
==
start_date
,
"
different start dates
"
assert
fchunk
.
index
.
max
()
==
end_date
,
"
different end dates
"
if
__name__
==
"
__main__
"
:
testTemporalPartitioning
()
This diff is collapsed.
Click to expand it.
test/test_evaluator.py
+
6
−
8
View file @
642b9c17
...
...
@@ -3,13 +3,14 @@
import
numpy
as
np
from
.testfuncs
import
printSuccess
,
printFailed
,
initData
,
initEmptyFlags
from
.testfuncs
import
initData
from
flagger
import
SimpleFlagger
from
dsl.evaluator
import
evalCondition
def
testConditions
():
data
=
initData
()
flags
=
initE
mptyFlags
(
data
)
flags
=
SimpleFlagger
().
e
mptyFlags
(
data
)
tests
=
[
(
"
this > 100
"
,
...
...
@@ -25,14 +26,12 @@ def testConditions():
for
test
,
expected
in
tests
:
idx
=
evalCondition
(
test
,
data
,
flags
,
data
.
columns
[
0
])
assert
(
idx
==
expected
).
all
(),
printFailed
(
test
)
printSuccess
()
assert
(
idx
==
expected
).
all
()
def
testMissingIdentifier
():
data
=
initData
()
flags
=
initE
mptyFlags
(
data
)
flags
=
SimpleFlagger
().
e
mptyFlags
(
data
)
tests
=
[
"
func(var2) < 5
"
,
"
var3 != NODATA
"
]
for
test
in
tests
:
try
:
...
...
@@ -40,8 +39,7 @@ def testMissingIdentifier():
except
NameError
:
continue
else
:
printFailed
(
test
)
printSuccess
()
raise
AssertionError
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
test/testfuncs.py
+
0
−
12
View file @
642b9c17
...
...
@@ -5,14 +5,6 @@ import numpy as np
import
pandas
as
pd
def
printSuccess
():
print
(
"
all tests passed
"
)
def
printFailed
(
test
):
print
(
"
test failed:
'
{:}
'"
.
format
(
test
))
def
initData
(
start_date
=
"
2017-01-01
"
,
end_date
=
"
2017-12-31
"
,
freq
=
"
1h
"
):
dates
=
pd
.
date_range
(
start
=
"
2017-01-01
"
,
end
=
"
2017-12-31
"
,
freq
=
"
1h
"
)
data
=
pd
.
DataFrame
(
...
...
@@ -20,7 +12,3 @@ def initData(start_date="2017-01-01", end_date="2017-12-31", freq="1h"):
"
var2
"
:
np
.
arange
(
len
(
dates
),
len
(
dates
)
*
2
)},
index
=
dates
)
return
data
def
initEmptyFlags
(
data
):
return
pd
.
DataFrame
(
index
=
data
.
index
,
columns
=
data
.
columns
)
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