Commit 2870d248 authored by Jason Lian's avatar Jason Lian
Browse files

Fixing a test in test_transforms.py which passes in a numpy array

parent bcba1814
...@@ -107,18 +107,7 @@ class Tester(unittest.TestCase): ...@@ -107,18 +107,7 @@ class Tester(unittest.TestCase):
def test_mu_law_companding(self): def test_mu_law_companding(self):
sig = self.sig.clone()
quantization_channels = 256 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 = self.sig.clone()
sig = sig / torch.abs(sig).max() sig = sig / torch.abs(sig).max()
......
...@@ -316,7 +316,7 @@ def mu_law_encoding(x, qc): ...@@ -316,7 +316,7 @@ def mu_law_encoding(x, qc):
Outputs: Outputs:
Tensor: Input after mu-law companding 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. mu = qc - 1.
if not x.dtype.is_floating_point: if not x.dtype.is_floating_point:
x = x.to(torch.float) x = x.to(torch.float)
...@@ -342,7 +342,7 @@ def mu_law_expanding(x_mu, qc): ...@@ -342,7 +342,7 @@ def mu_law_expanding(x_mu, qc):
Outputs: Outputs:
Tensor: Input after decoding 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. mu = qc - 1.
if not x_mu.dtype.is_floating_point: if not x_mu.dtype.is_floating_point:
x_mu = x_mu.to(torch.float) x_mu = x_mu.to(torch.float)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment