Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SOHViewer
Manage
Activity
Members
Labels
Plan
Issues
14
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
5
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
45a79030
Commit
45a79030
authored
2 years ago
by
Kien Le
Browse files
Options
Downloads
Patches
Plain Diff
Add breaking tests for downsample_waveform_chan
parent
12ad2f4d
No related branches found
Branches containing commit
No related tags found
1 merge request
!33
Add tests and refactor trim_downsample_WFChan
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_model/test_handling_data.py
+53
-4
53 additions, 4 deletions
tests/test_model/test_handling_data.py
with
53 additions
and
4 deletions
tests/test_model/test_handling_data.py
+
53
−
4
View file @
45a79030
...
...
@@ -14,6 +14,7 @@ from sohstationviewer.model.handling_data import (
get_eachDay5MinList
,
get_trimTPSData
,
trim_waveform_data
,
downsample_waveform_chan
)
ORIGINAL_CHAN_SIZE_LIMIT
=
const
.
CHAN_SIZE_LIMIT
...
...
@@ -148,17 +149,65 @@ class TestDownsampleWaveformData(TestCase):
trace
[
'
data_f
'
]
=
data_file_name
self
.
traces_info
.
append
(
trace
)
self
.
start_time
=
2500
self
.
end_time
=
7500
self
.
start_time
=
2550
self
.
end_time
=
7550
self
.
trimmed_traces_list
=
trim_waveform_data
(
self
.
channel_data
,
self
.
start_time
,
self
.
end_time
)
@patch
(
'
sohstationviewer.model.handling_data.downsample
'
,
wraps
=
downsample
)
def
test_data_is_downsampled
(
self
,
mock_downsample
):
const
.
CHAN_SIZE_LIMIT
=
1000
trim_
downsample_
WFC
han
(
self
.
channel_data
,
self
.
start_time
,
self
.
end_time
,
True
)
downsample_
waveform_c
han
(
self
.
channel_data
,
self
.
trimmed_traces_list
,
self
.
start_time
,
self
.
end_time
,
True
)
self
.
assertTrue
(
mock_downsample
.
called
)
const
.
CHAN_SIZE_LIMIT
=
ORIGINAL_CHAN_SIZE_LIMIT
def
test_all_traces_handled
(
self
):
downsampled_times
,
downsampled_data
=
downsample_waveform_chan
(
self
.
channel_data
,
self
.
trimmed_traces_list
,
self
.
start_time
,
self
.
end_time
,
True
)
self
.
assertEqual
(
len
(
downsampled_times
),
51
)
self
.
assertEqual
(
len
(
downsampled_data
),
51
)
def
test_downsampling_not_needed
(
self
):
downsampled_times
,
downsampled_data
=
downsample_waveform_chan
(
self
.
channel_data
,
self
.
trimmed_traces_list
,
self
.
start_time
,
self
.
end_time
,
True
)
with
self
.
subTest
(
'
test_data_points_outside_time_range_removed
'
):
self
.
assertEqual
(
downsampled_times
.
pop
[
0
].
size
,
50
)
self
.
assertEqual
(
downsampled_times
.
pop
[
-
1
].
size
,
50
)
self
.
assertEqual
(
downsampled_data
.
pop
[
0
].
size
,
50
)
self
.
assertEqual
(
downsampled_data
.
pop
[
-
1
].
size
,
50
)
with
self
.
subTest
(
'
test_intermediate_data_points_not_removed
'
):
self
.
assertTrue
(
all
(
times
.
size
==
100
for
times
in
downsampled_times
)
)
self
.
assertTrue
(
all
(
data
.
size
==
100
for
data
in
downsampled_times
)
)
def
test_trace_list_empty
(
self
):
self
.
trimmed_traces_list
=
[]
downsampled_times
,
downsampled_data
=
downsample_waveform_chan
(
self
.
channel_data
,
self
.
trimmed_traces_list
,
self
.
start_time
,
self
.
end_time
,
True
)
self
.
assertListEqual
(
downsampled_times
,
[])
self
.
assertListEqual
(
downsampled_data
,
[])
def
test_end_time_earlier_than_start_time
(
self
):
self
.
start_time
,
self
.
end_time
=
self
.
end_time
,
self
.
start_time
downsampled_times
,
downsampled_data
=
downsample_waveform_chan
(
self
.
channel_data
,
self
.
trimmed_traces_list
,
self
.
start_time
,
self
.
end_time
,
True
)
self
.
assertListEqual
(
downsampled_times
,
[])
self
.
assertListEqual
(
downsampled_data
,
[])
class
TestTrimDownsampleWfChan
(
TestCase
):
def
setUp
(
self
)
->
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