MCPcopy
hub / github.com/ibab/tensorflow-wavenet / testEncodeDecode

Method testEncodeDecode

test/test_mu_law.py:87–104  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

85 self.assertNear(y_intercept, 0.0, EPSILON)
86
87 def testEncodeDecode(self):
88 x = np.linspace(-1, 1, 1000).astype(np.float32)
89 channels = 256
90
91 # Test whether decoded signal is roughly equal to
92 # what was encoded before
93 with self.test_session() as sess:
94 encoded = mu_law_encode(x, channels)
95 x1 = sess.run(mu_law_decode(encoded, channels))
96
97 self.assertAllClose(x, x1, rtol=1e-1, atol=0.05)
98
99 # Make sure that re-encoding leaves the waveform invariant
100 with self.test_session() as sess:
101 encoded = mu_law_encode(x1, channels)
102 x2 = sess.run(mu_law_decode(encoded, channels))
103
104 self.assertAllClose(x1, x2)
105
106 def testEncodeIsSurjective(self):
107 x = np.linspace(-1, 1, 10000).astype(np.float32)

Callers

nothing calls this directly

Calls 2

mu_law_encodeFunction · 0.90
mu_law_decodeFunction · 0.90

Tested by

no test coverage detected