MCPcopy Create free account
hub / github.com/PyWavelets/pywt / test_wavelet_packet_axis

Function test_wavelet_packet_axis

pywt/tests/test_wp.py:209–233  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

207
208
209def 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
236def test_wavelet_packet_pickle(tmpdir):

Callers

nothing calls this directly

Calls 2

get_levelMethod · 0.95
reconstructMethod · 0.95

Tested by

no test coverage detected