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
21269247
Unverified
Commit
21269247
authored
Apr 03, 2020
by
moto
Committed by
GitHub
Apr 03, 2020
Browse files
Fix incomplete tests in batch and transforms (#506)
* Fix test_compute_deltas_twochannels * Fix 3batch test helper
parent
d1adb7f6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
test/test_batch_consistency.py
test/test_batch_consistency.py
+4
-1
test/test_transforms.py
test/test_transforms.py
+5
-4
No files found.
test/test_batch_consistency.py
View file @
21269247
...
@@ -64,7 +64,10 @@ def _test_batch(functional, tensor, *args, **kwargs):
...
@@ -64,7 +64,10 @@ def _test_batch(functional, tensor, *args, **kwargs):
expected
=
expected
.
repeat
(
*
ind
)
expected
=
expected
.
repeat
(
*
ind
)
torch
.
random
.
manual_seed
(
42
)
torch
.
random
.
manual_seed
(
42
)
_
=
functional
(
tensors
.
clone
(),
*
args
,
**
kwargs
)
computed
=
functional
(
tensors
.
clone
(),
*
args
,
**
kwargs
)
assert
expected
.
shape
==
computed
.
shape
,
(
expected
.
shape
,
computed
.
shape
)
assert
torch
.
allclose
(
expected
,
computed
,
**
kwargs_compare
)
class
TestFunctional
(
unittest
.
TestCase
):
class
TestFunctional
(
unittest
.
TestCase
):
...
...
test/test_transforms.py
View file @
21269247
...
@@ -212,11 +212,12 @@ class Tester(unittest.TestCase):
...
@@ -212,11 +212,12 @@ class Tester(unittest.TestCase):
def
test_compute_deltas_twochannel
(
self
):
def
test_compute_deltas_twochannel
(
self
):
specgram
=
torch
.
tensor
([
1.
,
2.
,
3.
,
4.
]).
repeat
(
1
,
2
,
1
)
specgram
=
torch
.
tensor
([
1.
,
2.
,
3.
,
4.
]).
repeat
(
1
,
2
,
1
)
_
=
torch
.
tensor
([[[
0.5
,
1.0
,
1.0
,
0.5
],
expected
=
torch
.
tensor
([[[
0.5
,
1.0
,
1.0
,
0.5
],
[
0.5
,
1.0
,
1.0
,
0.5
]]])
[
0.5
,
1.0
,
1.0
,
0.5
]]])
transform
=
transforms
.
ComputeDeltas
()
transform
=
transforms
.
ComputeDeltas
(
win_length
=
3
)
computed
=
transform
(
specgram
)
computed
=
transform
(
specgram
)
self
.
assertTrue
(
computed
.
shape
==
specgram
.
shape
,
(
computed
.
shape
,
specgram
.
shape
))
assert
computed
.
shape
==
expected
.
shape
,
(
computed
.
shape
,
expected
.
shape
)
assert
torch
.
allclose
(
computed
,
expected
,
atol
=
1e-6
,
rtol
=
1e-8
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
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