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

Function test_reconstructing_data

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

Source from the content-addressed store, hash-verified

87
88
89def test_reconstructing_data():
90 x = [1, 2, 3, 4, 5, 6, 7, 8]
91 wp = pywt.WaveletPacket(data=x, wavelet='db1', mode='symmetric')
92
93 # Create another Wavelet Packet and feed it with some data.
94 new_wp = pywt.WaveletPacket(data=None, wavelet='db1', mode='symmetric')
95 new_wp['aa'] = wp['aa'].data
96 new_wp['ad'] = [-2., -2.]
97
98 # For convenience, :attr:`Node.data` gets automatically extracted
99 # from the :class:`Node` object:
100 new_wp['d'] = wp['d']
101
102 # Reconstruct data from aa, ad, and d packets.
103 assert_allclose(new_wp.reconstruct(update=False), x, rtol=1e-12)
104
105 # The node's :attr:`~Node.data` will not be updated
106 assert_(new_wp.data is None)
107
108 # When `update` is True:
109 assert_allclose(new_wp.reconstruct(update=True), x, rtol=1e-12)
110 assert_allclose(new_wp.data, np.arange(1, 9), rtol=1e-12)
111
112 assert_([n.path for n in new_wp.get_leaf_nodes(False)] ==
113 ['aa', 'ad', 'd'])
114 assert_([n.path for n in new_wp.get_leaf_nodes(True)] ==
115 ['aaa', 'aad', 'ada', 'add', 'daa', 'dad', 'dda', 'ddd'])
116
117
118def test_removing_nodes():

Callers

nothing calls this directly

Calls 2

reconstructMethod · 0.95
get_leaf_nodesMethod · 0.80

Tested by

no test coverage detected