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
a2b62a86
Commit
a2b62a86
authored
4 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
some tests
parent
e7d0bc07
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!218
Flags
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/flagger/test_backtrack.py
+87
-0
87 additions, 0 deletions
test/flagger/test_backtrack.py
with
87 additions
and
0 deletions
test/flagger/test_backtrack.py
0 → 100644
+
87
−
0
View file @
a2b62a86
#!/usr/bin/env python
import
pytest
import
numpy
as
np
import
pandas
as
pd
from
pandas.api.types
import
is_bool_dtype
from
test.common
import
TESTFLAGGER
,
initData
from
saqc.flagger.backtrack
import
Backtrack
data
=
[
np
.
array
([[]]),
np
.
zeros
((
1
,
1
)),
np
.
zeros
((
3
,
4
)),
np
.
ones
((
3
,
4
)),
np
.
ones
((
3
,
4
))
*
np
.
nan
,
np
.
array
([
[
0
,
0
,
0
,
0
],
[
0
,
1
,
2
,
3
],
[
0
,
1
,
2
,
3
],
]),
np
.
array
([
[
0
,
0
,
0
,
0
],
[
0
,
1
,
np
.
nan
,
3
],
[
0
,
1
,
2
,
3
],
]),
]
def
check_invariants
(
bt
):
"""
this can be called for **any** BT and
should never fail.
"""
# basics
assert
isinstance
(
bt
,
Backtrack
)
assert
isinstance
(
bt
.
bt
,
pd
.
DataFrame
)
assert
isinstance
(
bt
.
mask
,
pd
.
DataFrame
)
assert
all
(
bt
.
bt
.
dtypes
==
float
)
assert
all
(
bt
.
mask
.
dtypes
==
bool
)
assert
bt
.
bt
.
columns
.
equals
(
bt
.
mask
.
columns
)
assert
bt
.
columns
is
bt
.
bt
.
columns
assert
bt
.
index
is
bt
.
bt
.
index
assert
len
(
bt
)
==
len
(
bt
.
columns
)
# advanced
assert
bt
.
columns
.
equals
(
pd
.
Index
(
range
(
len
(
bt
))))
assert
isinstance
(
bt
.
max
(),
pd
.
Series
)
@pytest.mark.parametrize
(
'
data
'
,
data
+
[
None
])
def
test_init
(
data
:
np
.
array
):
df
=
pd
.
DataFrame
(
data
,
dtype
=
float
)
bt
=
Backtrack
(
bt
=
df
)
check_invariants
(
bt
)
# shape would fail
if
data
is
not
None
:
assert
len
(
bt
.
index
)
==
data
.
shape
[
0
]
assert
len
(
bt
.
columns
)
==
data
.
shape
[
1
]
assert
bt
.
mask
.
all
(
axis
=
None
)
# check fastpath
bt
=
Backtrack
(
bt
=
bt
)
check_invariants
(
bt
)
@pytest.mark.parametrize
(
'
data
'
,
data
+
[
None
])
def
test_init_with_mask
(
data
:
np
.
array
):
df
=
pd
.
DataFrame
(
data
,
dtype
=
float
)
bt
=
Backtrack
(
bt
=
df
)
check_invariants
(
bt
)
if
data
is
None
:
return
assert
len
(
bt
.
index
)
==
data
.
shape
[
0
]
assert
len
(
bt
.
columns
)
==
data
.
shape
[
1
]
assert
bt
.
mask
.
all
(
axis
=
None
)
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