()
| 207 | |
| 208 | |
| 209 | def test_wavelet_packet_axis(): |
| 210 | rstate = np.random.RandomState(0) |
| 211 | shape = (32, 16) |
| 212 | x = rstate.standard_normal(shape) |
| 213 | for axis in [0, 1, -1]: |
| 214 | wp = pywt.WaveletPacket(data=x, wavelet='db1', mode='symmetric', |
| 215 | axis=axis) |
| 216 | |
| 217 | # partial decomposition |
| 218 | nodes = wp.get_level(2) |
| 219 | # size along the transformed axis has changed |
| 220 | for ax2 in range(x.ndim): |
| 221 | if ax2 == (axis % x.ndim): |
| 222 | nodes[0].data.shape[ax2] < x.shape[ax2] |
| 223 | else: |
| 224 | nodes[0].data.shape[ax2] == x.shape[ax2] |
| 225 | |
| 226 | # recontsruction from coefficients should preserve dtype |
| 227 | r = wp.reconstruct(False) |
| 228 | assert_equal(r.dtype, x.dtype) |
| 229 | assert_allclose(r, x, atol=1e-12, rtol=1e-12) |
| 230 | |
| 231 | # ValueError if axis is out of range |
| 232 | assert_raises(ValueError, pywt.WaveletPacket, data=x, wavelet='db1', |
| 233 | axis=x.ndim) |
| 234 | |
| 235 | |
| 236 | def test_wavelet_packet_pickle(tmpdir): |
nothing calls this directly
no test coverage detected