Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sgn-ts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
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
greg
sgn-ts
Commits
ab8cf38d
Commit
ab8cf38d
authored
1 month ago
by
Jameson Rollins
Browse files
Options
Downloads
Plain Diff
Merge branch 'add-const-to-fakeseries-src' into 'main'
Add new mode to FakeSeriesSource See merge request
!114
parents
0925cbba
57cbdc21
No related branches found
Branches containing commit
No related tags found
1 merge request
!114
Add new mode to FakeSeriesSource
Pipeline
#712702
failed
1 month ago
Stage: build
Stage: test
Stage: deploy
Stage: .post
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sgnts/sources/fake_series.py
+8
-2
8 additions, 2 deletions
src/sgnts/sources/fake_series.py
tests/sources/test_fake_series.py
+71
-2
71 additions, 2 deletions
tests/sources/test_fake_series.py
with
79 additions
and
4 deletions
src/sgnts/sources/fake_series.py
+
8
−
2
View file @
ab8cf38d
...
...
@@ -2,7 +2,7 @@ from __future__ import annotations
import
time
from
dataclasses
import
dataclass
from
typing
import
Optional
from
typing
import
Optional
,
Union
import
numpy
as
np
from
sgn.base
import
SourcePad
,
get_sgn_logger
...
...
@@ -35,9 +35,12 @@ class FakeSeriesSource(TSSource):
signal_type:
str, currently supported types: (1)
'
white
'
: white noise data. (2)
'
sin
'
or
'
sine
'
: sine wave data. (3)
'
impulse
'
: creates an impulse data, where the
value is one at one sample point, and everywhere else is zero
value is one at one sample point, and everywhere else is zero.
(4)
'
const
'
: constant values as specified by user.
fsin:
float, the frequency of the sine wave if signal_type =
'
sin
'
const:
int | float, the constant int or float for output
ngap:
int, the frequency to generate gap buffers, will generate a gap buffer every
ngap buffers. ngap=0: do not generate gap buffers. ngap=-1: generates gap
...
...
@@ -59,6 +62,7 @@ class FakeSeriesSource(TSSource):
sample_shape
:
tuple
[
int
,
...]
=
()
signal_type
:
str
=
"
white
"
fsin
:
float
=
5
const
:
Union
[
int
,
float
]
=
1
ngap
:
int
=
0
random_seed
:
Optional
[
int
]
=
None
impulse_position
:
int
=
-
1
...
...
@@ -154,6 +158,8 @@ class FakeSeriesSource(TSSource):
)
elif
self
.
signal_type
==
"
impulse
"
:
return
self
.
create_impulse_data
(
offset
,
buf
.
samples
,
buf
.
sample_rate
)
elif
self
.
signal_type
==
"
const
"
:
return
np
.
full
(
buf
.
shape
,
self
.
const
)
else
:
raise
ValueError
(
"
Unknown signal type
"
)
...
...
This diff is collapsed.
Click to expand it.
tests/sources/test_fake_series.py
+
71
−
2
View file @
ab8cf38d
"""
Tests for the fake_series module.
"""
"""
Tests for the fake_series module.
"""
import
numpy
...
...
@@ -113,3 +112,73 @@ class TestFakeSeriesSource:
]
)
numpy
.
testing
.
assert_almost_equal
(
res
.
buffers
[
0
].
data
,
expected
,
decimal
=
5
)
def
test_const_int
(
self
):
"""
Test the constant int generation
"""
src
=
FakeSeriesSource
(
name
=
"
test
"
,
rate
=
16
,
signal_type
=
"
const
"
,
const
=
2
,
t0
=
0
,
duration
=
1
,
source_pad_names
=
[
"
S1
"
],
)
res
=
src
.
new
(
pad
=
src
.
srcs
[
"
S1
"
])
assert
isinstance
(
res
,
TSFrame
)
expected
=
numpy
.
array
(
[
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
]
)
numpy
.
testing
.
assert_equal
(
res
.
buffers
[
0
].
data
,
expected
)
def
test_const_float
(
self
):
"""
Test the constant float generation
"""
src
=
FakeSeriesSource
(
name
=
"
test
"
,
rate
=
16
,
signal_type
=
"
const
"
,
const
=
3.4
,
t0
=
0
,
duration
=
1
,
source_pad_names
=
[
"
S1
"
],
)
res
=
src
.
new
(
pad
=
src
.
srcs
[
"
S1
"
])
assert
isinstance
(
res
,
TSFrame
)
expected
=
numpy
.
array
(
[
3.4
,
3.4
,
3.4
,
3.4
,
3.4
,
3.4
,
3.4
,
3.4
,
3.4
,
3.4
,
3.4
,
3.4
,
3.4
,
3.4
,
3.4
,
3.4
,
]
)
numpy
.
testing
.
assert_equal
(
res
.
buffers
[
0
].
data
,
expected
)
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