Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
madarrays
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
skmad-suite
madarrays
Commits
8e57c9b7
There was a problem fetching the pipeline summary.
Commit
8e57c9b7
authored
6 years ago
by
valentin.emiya
Browse files
Options
Downloads
Patches
Plain Diff
fix bug in resample test (now understood)
parent
131e78e1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
madarrays/tests/test_waveform.py
+5
-7
5 additions, 7 deletions
madarrays/tests/test_waveform.py
madarrays/waveform.py
+4
-4
4 additions, 4 deletions
madarrays/waveform.py
with
9 additions
and
11 deletions
madarrays/tests/test_waveform.py
+
5
−
7
View file @
8e57c9b7
...
...
@@ -243,34 +243,32 @@ class TestWaveform:
w
.
resample
(
fs
=
fs
)
assert
w
.
fs
==
fs
assert
w
.
length
==
int
(
np
.
floor
(
fs
*
self
.
length
/
self
.
fs
))
assert
w
.
length
==
int
(
np
.
floor
(
fs
/
self
.
fs
*
self
.
length
))
assert
not
w
.
is_stereo
()
print
(
self
.
length
,
self
.
fs
)
assert
w
.
duration
==
pytest
.
approx
(
self
.
length
/
self
.
fs
,
1e-4
)
np
.
testing
.
assert_equal
(
w
.
time_axis
,
np
.
arange
(
np
.
floor
(
fs
*
self
.
length
/
self
.
fs
))
/
fs
)
np
.
arange
(
np
.
floor
(
fs
/
self
.
fs
*
self
.
length
))
/
fs
)
# Stereo
w
=
Waveform
(
self
.
x_stereo
,
fs
=
self
.
fs
)
w
.
resample
(
fs
=
fs
)
assert
w
.
fs
==
fs
assert
w
.
length
==
int
(
np
.
floor
(
fs
*
self
.
length
/
self
.
fs
))
assert
w
.
length
==
int
(
np
.
floor
(
fs
/
self
.
fs
*
self
.
length
))
assert
w
.
is_stereo
()
assert
w
.
duration
==
pytest
.
approx
(
self
.
length
/
self
.
fs
,
1e-4
)
np
.
testing
.
assert_equal
(
w
.
time_axis
,
np
.
arange
(
np
.
floor
(
fs
*
self
.
length
/
self
.
fs
))
/
fs
)
np
.
arange
(
np
.
floor
(
fs
/
self
.
fs
*
self
.
length
))
/
fs
)
# Floating values with ratios that are exact rationals
for
(
old_fs
,
new_fs
)
in
[(
1
,
1.5
),
(
0.5
,
3
),
(
100.1
,
200.2
)]:
print
(
'
Testing resampling {}/{}, signal length = {}
'
.
format
(
new_fs
,
old_fs
,
w
.
shape
[
0
]))
w
=
Waveform
(
self
.
x_mono
,
fs
=
old_fs
)
w
.
resample
(
fs
=
new_fs
)
assert
w
.
fs
==
new_fs
assert
w
.
length
==
int
(
new_fs
*
self
.
length
/
old_fs
)
assert
w
.
length
==
int
(
new_fs
/
old_fs
*
self
.
length
)
# Floating values with ratios that are not well approximated
# by rationals
...
...
This diff is collapsed.
Click to expand it.
madarrays/waveform.py
+
4
−
4
View file @
8e57c9b7
...
...
@@ -310,15 +310,15 @@ class Waveform(MadArray):
UserWarning
"""
assert
np
.
issubdtype
(
type
(
fs
),
np
.
integer
)
or
np
.
issubdtype
(
type
(
fs
),
np
.
float
)
assert
np
.
issubdtype
(
type
(
fs
),
np
.
integer
)
\
or
np
.
issubdtype
(
type
(
fs
),
np
.
float
ing
)
if
fs
<=
0
:
errmsg
=
'
`fs` should be a positive number (given: {})
'
raise
ValueError
(
errmsg
.
format
(
fs
))
if
np
.
issubdtype
(
type
(
fs
),
np
.
float
)
or
np
.
issubdtype
(
type
(
self
.
fs
),
np
.
float
):
if
np
.
issubdtype
(
type
(
fs
),
np
.
float
ing
)
\
or
np
.
issubdtype
(
type
(
self
.
fs
),
np
.
float
ing
):
# Find a good rational number to approximate the ratio between
# sampling frequencies
fs_ratio
=
Fraction
(
fs
/
self
.
fs
)
...
...
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