Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SOHViewer
Manage
Activity
Members
Labels
Plan
Issues
11
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
3
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software Public
PASSOFT
SOHViewer
Commits
2dfd3db3
Commit
2dfd3db3
authored
1 year ago
by
Lan Dam
Browse files
Options
Downloads
Patches
Plain Diff
unittest for combine_traces_except_gaps_overlaps
parent
60eefb1c
No related branches found
No related tags found
1 merge request
!119
separate data at gaps/overlaps
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_model/test_handling_data_rearrange_data.py
+60
-1
60 additions, 1 deletion
tests/test_model/test_handling_data_rearrange_data.py
with
60 additions
and
1 deletion
tests/test_model/test_handling_data_rearrange_data.py
+
60
−
1
View file @
2dfd3db3
import
numpy
as
np
from
unittest
import
TestCase
from
unittest
import
TestCase
from
sohstationviewer.model.handling_data
import
(
from
sohstationviewer.model.handling_data
import
(
sort_data
,
check_related_gaps
,
squash_gaps
sort_data
,
check_related_gaps
,
squash_gaps
,
combine_traces_except_gaps_overlaps
)
)
...
@@ -84,3 +86,60 @@ class TestSquashGaps(TestCase):
...
@@ -84,3 +86,60 @@ class TestSquashGaps(TestCase):
def
test_mixed_gaps
(
self
):
def
test_mixed_gaps
(
self
):
gaps
=
squash_gaps
((
self
.
mixed_gaps
))
gaps
=
squash_gaps
((
self
.
mixed_gaps
))
self
.
assertEqual
(
gaps
,
[[
3
,
8
],
[
18
,
13
]])
self
.
assertEqual
(
gaps
,
[[
3
,
8
],
[
18
,
13
]])
class
TestCombineTracesExceptGapsOverlaps
(
TestCase
):
def
test_combine
(
self
):
traces
=
[
{
'
samplerate
'
:
1
,
'
startTmEpoch
'
:
1
,
'
endTmEpoch
'
:
2
,
'
size
'
:
2
,
'
times
'
:
np
.
array
([
1
,
2
]),
'
data
'
:
np
.
array
([
0
,
0
])},
# overlap at the beginning
{
'
samplerate
'
:
1
,
'
startTmEpoch
'
:
1
,
'
endTmEpoch
'
:
3
,
'
size
'
:
3
,
'
times
'
:
np
.
array
([
1
,
2
,
3
]),
'
data
'
:
np
.
array
([
1
,
1
,
1
])},
{
'
samplerate
'
:
1
,
'
startTmEpoch
'
:
4
,
'
endTmEpoch
'
:
6
,
'
size
'
:
3
,
'
times
'
:
np
.
array
([
4
,
5
,
6
]),
'
data
'
:
np
.
array
([
2
,
2
,
2
])},
# gap
{
'
samplerate
'
:
1
,
'
startTmEpoch
'
:
8
,
'
endTmEpoch
'
:
10
,
'
size
'
:
3
,
'
times
'
:
np
.
array
([
8
,
9
,
10
]),
'
data
'
:
np
.
array
([
3
,
3
,
3
])},
{
'
samplerate
'
:
1
,
'
startTmEpoch
'
:
11
,
'
endTmEpoch
'
:
13
,
'
size
'
:
3
,
'
times
'
:
np
.
array
([
11
,
12
,
13
]),
'
data
'
:
np
.
array
([
4
,
4
,
4
])},
# overlap
{
'
samplerate
'
:
1
,
'
startTmEpoch
'
:
12
,
'
endTmEpoch
'
:
14
,
'
size
'
:
3
,
'
times
'
:
np
.
array
([
12
,
13
,
14
]),
'
data
'
:
np
.
array
([
5
,
5
,
5
])}
]
gaps
=
[[
2
,
1
],
[
6
,
8
],
[
13
,
12
]]
new_traces
=
combine_traces_except_gaps_overlaps
(
traces
,
gaps
)
self
.
assertEqual
(
len
(
new_traces
),
4
)
# Trace 0
self
.
assertEqual
(
new_traces
[
0
][
'
samplerate
'
],
1
)
self
.
assertEqual
(
new_traces
[
0
][
'
startTmEpoch
'
],
1
)
self
.
assertEqual
(
new_traces
[
0
][
'
endTmEpoch
'
],
2
)
self
.
assertEqual
(
new_traces
[
0
][
'
size
'
],
2
)
self
.
assertEqual
(
new_traces
[
0
][
'
times
'
].
tolist
(),
[
1
,
2
])
self
.
assertEqual
(
new_traces
[
0
][
'
data
'
].
tolist
(),
[
0
,
0
])
# Combine traces 1 & 2
self
.
assertEqual
(
new_traces
[
1
][
'
samplerate
'
],
1
)
self
.
assertEqual
(
new_traces
[
1
][
'
startTmEpoch
'
],
1
)
self
.
assertEqual
(
new_traces
[
1
][
'
endTmEpoch
'
],
6
)
self
.
assertEqual
(
new_traces
[
1
][
'
size
'
],
6
)
self
.
assertEqual
(
new_traces
[
1
][
'
times
'
].
tolist
(),
[
1
,
2
,
3
,
4
,
5
,
6
])
self
.
assertEqual
(
new_traces
[
1
][
'
data
'
].
tolist
(),
[
1
,
1
,
1
,
2
,
2
,
2
])
# Combine traces 3 & 4
self
.
assertEqual
(
new_traces
[
2
][
'
samplerate
'
],
1
)
self
.
assertEqual
(
new_traces
[
2
][
'
startTmEpoch
'
],
8
)
self
.
assertEqual
(
new_traces
[
2
][
'
endTmEpoch
'
],
13
)
self
.
assertEqual
(
new_traces
[
2
][
'
size
'
],
6
)
self
.
assertEqual
(
new_traces
[
2
][
'
times
'
].
tolist
(),
[
8
,
9
,
10
,
11
,
12
,
13
])
self
.
assertEqual
(
new_traces
[
2
][
'
data
'
].
tolist
(),
[
3
,
3
,
3
,
4
,
4
,
4
])
# Trace 5
self
.
assertEqual
(
new_traces
[
3
][
'
samplerate
'
],
1
)
self
.
assertEqual
(
new_traces
[
3
][
'
startTmEpoch
'
],
12
)
self
.
assertEqual
(
new_traces
[
3
][
'
endTmEpoch
'
],
14
)
self
.
assertEqual
(
new_traces
[
3
][
'
size
'
],
3
)
self
.
assertEqual
(
new_traces
[
3
][
'
times
'
].
tolist
(),
[
12
,
13
,
14
])
self
.
assertEqual
(
new_traces
[
3
][
'
data
'
].
tolist
(),
[
5
,
5
,
5
])
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