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
2870d248
Commit
2870d248
authored
May 20, 2019
by
Jason Lian
Browse files
Fixing a test in test_transforms.py which passes in a numpy array
parent
bcba1814
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
13 deletions
+2
-13
test/test_transforms.py
test/test_transforms.py
+0
-11
torchaudio/functional.py
torchaudio/functional.py
+2
-2
No files found.
test/test_transforms.py
View file @
2870d248
...
...
@@ -107,18 +107,7 @@ class Tester(unittest.TestCase):
def
test_mu_law_companding
(
self
):
sig
=
self
.
sig
.
clone
()
quantization_channels
=
256
sig
=
self
.
sig
.
numpy
()
sig
=
sig
/
np
.
abs
(
sig
).
max
()
self
.
assertTrue
(
sig
.
min
()
>=
-
1.
and
sig
.
max
()
<=
1.
)
sig_mu
=
transforms
.
MuLawEncoding
(
quantization_channels
)(
sig
)
self
.
assertTrue
(
sig_mu
.
min
()
>=
0.
and
sig
.
max
()
<=
quantization_channels
)
sig_exp
=
transforms
.
MuLawExpanding
(
quantization_channels
)(
sig_mu
)
self
.
assertTrue
(
sig_exp
.
min
()
>=
-
1.
and
sig_exp
.
max
()
<=
1.
)
sig
=
self
.
sig
.
clone
()
sig
=
sig
/
torch
.
abs
(
sig
).
max
()
...
...
torchaudio/functional.py
View file @
2870d248
...
...
@@ -316,7 +316,7 @@ def mu_law_encoding(x, qc):
Outputs:
Tensor: Input after mu-law companding
"""
assert
(
isinstance
(
x
,
torch
.
Tensor
)
)
,
'mu_law_encoding expects a Tensor'
assert
isinstance
(
x
,
torch
.
Tensor
),
'mu_law_encoding expects a Tensor'
mu
=
qc
-
1.
if
not
x
.
dtype
.
is_floating_point
:
x
=
x
.
to
(
torch
.
float
)
...
...
@@ -342,7 +342,7 @@ def mu_law_expanding(x_mu, qc):
Outputs:
Tensor: Input after decoding
"""
assert
(
isinstance
(
x_mu
,
torch
.
Tensor
)
)
,
'mu_law_expanding expects a Tensor'
assert
isinstance
(
x_mu
,
torch
.
Tensor
),
'mu_law_expanding expects a Tensor'
mu
=
qc
-
1.
if
not
x_mu
.
dtype
.
is_floating_point
:
x_mu
=
x_mu
.
to
(
torch
.
float
)
...
...
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