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
3781cb23
Unverified
Commit
3781cb23
authored
Jul 21, 2020
by
top0coder
Committed by
GitHub
Jul 21, 2020
Browse files
Remove if __name__ == __main__ from test code (#804)
Co-authored-by:
Jeff Zhang
<
jeffzhang@fb.com
>
parent
fac1bba9
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
0 additions
and
43 deletions
+0
-43
test/functional_cpu_test.py
test/functional_cpu_test.py
+0
-4
test/test_batch_consistency.py
test/test_batch_consistency.py
+0
-4
test/test_compliance_kaldi.py
test/test_compliance_kaldi.py
+0
-4
test/test_dataloader.py
test/test_dataloader.py
+0
-4
test/test_datasets.py
test/test_datasets.py
+0
-4
test/test_io.py
test/test_io.py
+0
-3
test/test_kaldi_io.py
test/test_kaldi_io.py
+0
-4
test/test_librosa_compatibility.py
test/test_librosa_compatibility.py
+0
-4
test/test_sox_compatibility.py
test/test_sox_compatibility.py
+0
-4
test/test_sox_effects.py
test/test_sox_effects.py
+0
-4
test/test_transforms.py
test/test_transforms.py
+0
-4
No files found.
test/functional_cpu_test.py
View file @
3781cb23
...
@@ -405,7 +405,3 @@ def test_mask_along_axis_iid(mask_param, mask_value, axis):
...
@@ -405,7 +405,3 @@ def test_mask_along_axis_iid(mask_param, mask_value, axis):
assert
mask_specgrams
.
size
()
==
specgrams
.
size
()
assert
mask_specgrams
.
size
()
==
specgrams
.
size
()
assert
(
num_masked_columns
<
mask_param
).
sum
()
==
num_masked_columns
.
numel
()
assert
(
num_masked_columns
<
mask_param
).
sum
()
==
num_masked_columns
.
numel
()
if
__name__
==
'__main__'
:
unittest
.
main
()
test/test_batch_consistency.py
View file @
3781cb23
...
@@ -288,7 +288,3 @@ class TestTransforms(common_utils.TorchaudioTestCase):
...
@@ -288,7 +288,3 @@ class TestTransforms(common_utils.TorchaudioTestCase):
# Batch then transform
# Batch then transform
computed
=
torchaudio
.
transforms
.
Vol
(
gain
=
1.1
)(
waveform
.
repeat
(
3
,
1
,
1
))
computed
=
torchaudio
.
transforms
.
Vol
(
gain
=
1.1
)(
waveform
.
repeat
(
3
,
1
,
1
))
self
.
assertEqual
(
computed
,
expected
)
self
.
assertEqual
(
computed
,
expected
)
if
__name__
==
'__main__'
:
unittest
.
main
()
test/test_compliance_kaldi.py
View file @
3781cb23
...
@@ -246,7 +246,3 @@ class Test_Kaldi(common_utils.TempDirMixin, common_utils.TorchaudioTestCase):
...
@@ -246,7 +246,3 @@ class Test_Kaldi(common_utils.TempDirMixin, common_utils.TorchaudioTestCase):
single_channel_sampled
=
kaldi
.
resample_waveform
(
single_channel
,
self
.
test1_signal_sr
,
single_channel_sampled
=
kaldi
.
resample_waveform
(
single_channel
,
self
.
test1_signal_sr
,
self
.
test1_signal_sr
//
2
)
self
.
test1_signal_sr
//
2
)
torch
.
testing
.
assert_allclose
(
multi_sound_sampled
[
i
,
:],
single_channel_sampled
[
0
],
rtol
=
1e-4
,
atol
=
1e-7
)
torch
.
testing
.
assert_allclose
(
multi_sound_sampled
[
i
,
:],
single_channel_sampled
[
0
],
rtol
=
1e-4
,
atol
=
1e-7
)
if
__name__
==
'__main__'
:
unittest
.
main
()
test/test_dataloader.py
View file @
3781cb23
...
@@ -37,7 +37,3 @@ class Test_DataLoader(common_utils.TorchaudioTestCase):
...
@@ -37,7 +37,3 @@ class Test_DataLoader(common_utils.TorchaudioTestCase):
dl
=
DataLoader
(
ds
,
batch_size
=
2
)
dl
=
DataLoader
(
ds
,
batch_size
=
2
)
for
x
in
dl
:
for
x
in
dl
:
self
.
assertTrue
(
x
.
size
()
==
expected_size
)
self
.
assertTrue
(
x
.
size
()
==
expected_size
)
if
__name__
==
'__main__'
:
unittest
.
main
()
test/test_datasets.py
View file @
3781cb23
...
@@ -171,7 +171,3 @@ class TestLibriTTS(TempDirMixin, TorchaudioTestCase):
...
@@ -171,7 +171,3 @@ class TestLibriTTS(TempDirMixin, TorchaudioTestCase):
assert
original_text
==
self
.
original_text
assert
original_text
==
self
.
original_text
assert
normalized_text
==
self
.
normalized_text
assert
normalized_text
==
self
.
normalized_text
assert
utterance_id
==
f
'
{
"_"
.
join
(
str
(
u
)
for
u
in
expected_ids
[
-
4
:])
}
'
assert
utterance_id
==
f
'
{
"_"
.
join
(
str
(
u
)
for
u
in
expected_ids
[
-
4
:])
}
'
if
__name__
==
"__main__"
:
unittest
.
main
()
test/test_io.py
View file @
3781cb23
...
@@ -282,6 +282,3 @@ class Test_LoadSave(unittest.TestCase):
...
@@ -282,6 +282,3 @@ class Test_LoadSave(unittest.TestCase):
self
.
assertEqual
(
si
.
length
,
samples
)
self
.
assertEqual
(
si
.
length
,
samples
)
self
.
assertEqual
(
si
.
rate
,
rate
)
self
.
assertEqual
(
si
.
rate
,
rate
)
self
.
assertEqual
(
ei
.
bits_per_sample
,
precision
)
self
.
assertEqual
(
ei
.
bits_per_sample
,
precision
)
if
__name__
==
'__main__'
:
unittest
.
main
()
test/test_kaldi_io.py
View file @
3781cb23
...
@@ -33,7 +33,3 @@ class Test_KaldiIO(common_utils.TorchaudioTestCase):
...
@@ -33,7 +33,3 @@ class Test_KaldiIO(common_utils.TorchaudioTestCase):
def
test_read_mat_ark
(
self
):
def
test_read_mat_ark
(
self
):
self
.
_test_helper
(
"mat.ark"
,
[
self
.
data1
,
self
.
data2
],
kio
.
read_mat_ark
,
torch
.
float32
)
self
.
_test_helper
(
"mat.ark"
,
[
self
.
data1
,
self
.
data2
],
kio
.
read_mat_ark
,
torch
.
float32
)
if
__name__
==
'__main__'
:
unittest
.
main
()
test/test_librosa_compatibility.py
View file @
3781cb23
...
@@ -347,7 +347,3 @@ class TestTransforms(common_utils.TorchaudioTestCase):
...
@@ -347,7 +347,3 @@ class TestTransforms(common_utils.TorchaudioTestCase):
# torch.dist(spec_lr, spec_ta, p=1)
# torch.dist(spec_lr, spec_ta, p=1)
# >>> tensor(943.2759)
# >>> tensor(943.2759)
assert
torch
.
dist
(
spec_orig
,
spec_ta
,
p
=
1
)
<
threshold
assert
torch
.
dist
(
spec_orig
,
spec_ta
,
p
=
1
)
<
threshold
if
__name__
==
'__main__'
:
unittest
.
main
()
test/test_sox_compatibility.py
View file @
3781cb23
...
@@ -299,7 +299,3 @@ class TestFunctionalFiltering(TempDirMixin, TorchaudioTestCase):
...
@@ -299,7 +299,3 @@ class TestFunctionalFiltering(TempDirMixin, TorchaudioTestCase):
data
,
path
=
self
.
get_whitenoise
()
data
,
path
=
self
.
get_whitenoise
()
result
=
F
.
lfilter
(
data
,
torch
.
tensor
([
a0
,
a1
,
a2
]),
torch
.
tensor
([
b0
,
b1
,
b2
]))
result
=
F
.
lfilter
(
data
,
torch
.
tensor
([
a0
,
a1
,
a2
]),
torch
.
tensor
([
b0
,
b1
,
b2
]))
self
.
assert_sox_effect
(
result
,
path
,
[
'biquad'
,
b0
,
b1
,
b2
,
a0
,
a1
,
a2
])
self
.
assert_sox_effect
(
result
,
path
,
[
'biquad'
,
b0
,
b1
,
b2
,
a0
,
a1
,
a2
])
if
__name__
==
"__main__"
:
unittest
.
main
()
test/test_sox_effects.py
View file @
3781cb23
...
@@ -270,7 +270,3 @@ class Test_SoxEffectsChain(common_utils.TorchaudioTestCase):
...
@@ -270,7 +270,3 @@ class Test_SoxEffectsChain(common_utils.TorchaudioTestCase):
y
=
vad
(
x_orig
)
y
=
vad
(
x_orig
)
self
.
assertTrue
(
x
.
allclose
(
y
,
rtol
=
1e-4
,
atol
=
1e-4
))
self
.
assertTrue
(
x
.
allclose
(
y
,
rtol
=
1e-4
,
atol
=
1e-4
))
if
__name__
==
'__main__'
:
unittest
.
main
()
test/test_transforms.py
View file @
3781cb23
...
@@ -219,7 +219,3 @@ class Tester(common_utils.TorchaudioTestCase):
...
@@ -219,7 +219,3 @@ class Tester(common_utils.TorchaudioTestCase):
computed
=
transform
(
specgram
)
computed
=
transform
(
specgram
)
assert
computed
.
shape
==
expected
.
shape
,
(
computed
.
shape
,
expected
.
shape
)
assert
computed
.
shape
==
expected
.
shape
,
(
computed
.
shape
,
expected
.
shape
)
self
.
assertEqual
(
computed
,
expected
,
atol
=
1e-6
,
rtol
=
1e-8
)
self
.
assertEqual
(
computed
,
expected
,
atol
=
1e-6
,
rtol
=
1e-8
)
if
__name__
==
'__main__'
:
unittest
.
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