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
5efdd533
Commit
5efdd533
authored
2 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
added ts_operator test
parent
ec6d77d8
No related branches found
No related tags found
1 merge request
!462
More tests
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/lib/test_ts_operators.py
+60
-0
60 additions, 0 deletions
tests/lib/test_ts_operators.py
with
60 additions
and
0 deletions
tests/lib/test_ts_operators.py
+
60
−
0
View file @
5efdd533
...
...
@@ -6,6 +6,7 @@ import pytest
import
saqc.lib.ts_operators
as
tsops
import
pandas
as
pd
from
pandas.testing
import
assert_series_equal
def
test_butterFilter
():
...
...
@@ -45,3 +46,62 @@ F = False
def
test__exceedConsecutiveNanLimit
(
arr
,
maxc
,
expected
):
result
=
tsops
.
_exceedConsecutiveNanLimit
(
arr
,
maxc
)
assert
result
is
expected
def
dtSeries
(
data
,
freq
=
"
1d
"
):
index
=
pd
.
date_range
(
start
=
"
2020
"
,
periods
=
len
(
data
),
freq
=
freq
)
return
pd
.
Series
(
data
=
data
,
index
=
index
,
dtype
=
float
)
@pytest.mark.parametrize
(
"
func,data,expected
"
,
[
(
"
identity
"
,
dtSeries
([
1
,
2
]),
dtSeries
([
1
,
2
])),
(
"
count
"
,
dtSeries
([
0
,
0
]),
dtSeries
([
2
])),
pytest
.
param
(
"
first
"
,
dtSeries
([
1
,
2
]),
dtSeries
([
1
,
1
]),
marks
=
pytest
.
mark
.
xfail
(
reason
=
"
BUG (the inner ts.first need an argument)
"
),
),
pytest
.
param
(
"
last
"
,
dtSeries
([
1
,
2
]),
dtSeries
([
1
,
1
]),
marks
=
pytest
.
mark
.
xfail
(
reason
=
"
BUG (the inner ts.last need an argument)
"
),
),
(
"
zeroLog
"
,
dtSeries
([
1
,
2
,
np
.
inf
,
np
.
nan
]),
dtSeries
([
np
.
log
(
1
),
np
.
log
(
2
),
np
.
inf
,
np
.
nan
]),
),
pytest
.
param
(
"
zeroLog
"
,
dtSeries
(
[
# 0,
-
2
,
-
1
,
-
np
.
inf
,
]
),
dtSeries
([
np
.
nan
,
np
.
nan
,
np
.
nan
]),
marks
=
pytest
.
mark
.
xfail
(
reason
=
"
zeroLog(0) did not return NaN
"
),
),
],
)
def
test_tsop_functions
(
func
,
data
,
expected
):
f
=
getattr
(
tsops
,
func
)
resampler
=
data
.
resample
(
"
2d
"
)
result
=
resampler
.
apply
(
f
)
assert
isinstance
(
result
,
pd
.
Series
)
print
()
print
(
result
)
print
()
print
(
expected
)
assert_series_equal
(
result
,
expected
,
check_names
=
False
,
check_freq
=
False
,
check_dtype
=
False
)
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