Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Torchaudio
Commits
af88b925
"...text-generation-inference.git" did not exist on "0d96468ebb1ca0141d7a23b2fdfcef9a7ef7bb81"
Unverified
Commit
af88b925
authored
Apr 14, 2020
by
moto
Committed by
GitHub
Apr 14, 2020
Browse files
Move lfilter basic test to test_functional (#539)
parent
6304db75
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
25 deletions
+36
-25
test/test_functional.py
test/test_functional.py
+36
-0
test/test_sox_compatibility.py
test/test_sox_compatibility.py
+0
-25
No files found.
test/test_functional.py
View file @
af88b925
...
@@ -10,6 +10,42 @@ import pytest
...
@@ -10,6 +10,42 @@ import pytest
import
common_utils
import
common_utils
class
_LfilterMixin
:
device
=
None
dtype
=
None
def
test_simple
(
self
):
"""
Create a very basic signal,
Then make a simple 4th order delay
The output should be same as the input but shifted
"""
torch
.
random
.
manual_seed
(
42
)
waveform
=
torch
.
rand
(
2
,
44100
*
1
,
dtype
=
self
.
dtype
,
device
=
self
.
device
)
b_coeffs
=
torch
.
tensor
([
0
,
0
,
0
,
1
],
dtype
=
self
.
dtype
,
device
=
self
.
device
)
a_coeffs
=
torch
.
tensor
([
1
,
0
,
0
,
0
],
dtype
=
self
.
dtype
,
device
=
self
.
device
)
output_waveform
=
F
.
lfilter
(
waveform
,
a_coeffs
,
b_coeffs
)
torch
.
testing
.
assert_allclose
(
output_waveform
[:,
3
:],
waveform
[:,
0
:
-
3
],
atol
=
1e-5
,
rtol
=
1e-5
)
class
TestLfilterFloat32CPU
(
_LfilterMixin
,
unittest
.
TestCase
):
device
=
torch
.
device
(
'cpu'
)
dtype
=
torch
.
float32
class
TestLfilterFloat64CPU
(
_LfilterMixin
,
unittest
.
TestCase
):
device
=
torch
.
device
(
'cpu'
)
dtype
=
torch
.
float64
@
unittest
.
skipIf
(
not
torch
.
cuda
.
is_available
(),
"CUDA not available"
)
class
TestLfilterFloat32CUDA
(
_LfilterMixin
,
unittest
.
TestCase
):
device
=
torch
.
device
(
'cuda'
)
dtype
=
torch
.
float32
class
TestComputeDeltas
(
unittest
.
TestCase
):
class
TestComputeDeltas
(
unittest
.
TestCase
):
"""Test suite for correctness of compute_deltas"""
"""Test suite for correctness of compute_deltas"""
def
test_one_channel
(
self
):
def
test_one_channel
(
self
):
...
...
test/test_sox_compatibility.py
View file @
af88b925
...
@@ -12,31 +12,6 @@ from common_utils import AudioBackendScope, BACKENDS, create_temp_assets_dir
...
@@ -12,31 +12,6 @@ from common_utils import AudioBackendScope, BACKENDS, create_temp_assets_dir
class
TestFunctionalFiltering
(
unittest
.
TestCase
):
class
TestFunctionalFiltering
(
unittest
.
TestCase
):
test_dirpath
,
test_dir
=
create_temp_assets_dir
()
test_dirpath
,
test_dir
=
create_temp_assets_dir
()
def
_test_lfilter_basic
(
self
,
dtype
,
device
):
"""
Create a very basic signal,
Then make a simple 4th order delay
The output should be same as the input but shifted
"""
torch
.
random
.
manual_seed
(
42
)
waveform
=
torch
.
rand
(
2
,
44100
*
1
,
dtype
=
dtype
,
device
=
device
)
b_coeffs
=
torch
.
tensor
([
0
,
0
,
0
,
1
],
dtype
=
dtype
,
device
=
device
)
a_coeffs
=
torch
.
tensor
([
1
,
0
,
0
,
0
],
dtype
=
dtype
,
device
=
device
)
output_waveform
=
F
.
lfilter
(
waveform
,
a_coeffs
,
b_coeffs
)
torch
.
testing
.
assert_allclose
(
output_waveform
[:,
3
:],
waveform
[:,
0
:
-
3
],
atol
=
1e-5
,
rtol
=
1e-5
)
def
test_lfilter_basic
(
self
):
self
.
_test_lfilter_basic
(
torch
.
float32
,
torch
.
device
(
"cpu"
))
def
test_lfilter_basic_double
(
self
):
self
.
_test_lfilter_basic
(
torch
.
float64
,
torch
.
device
(
"cpu"
))
@
unittest
.
skipIf
(
not
torch
.
cuda
.
is_available
(),
"CUDA not available"
)
def
test_lfilter_basic_gpu
(
self
):
self
.
_test_lfilter_basic
(
torch
.
float32
,
torch
.
device
(
"cuda:0"
))
def
_test_lfilter
(
self
,
waveform
,
device
):
def
_test_lfilter
(
self
,
waveform
,
device
):
"""
"""
Design an IIR lowpass filter using scipy.signal filter design
Design an IIR lowpass filter using scipy.signal filter design
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment