(self)
| 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) |
nothing calls this directly
no test coverage detected