Skip to content

Conversation

@grlee77
Copy link
Contributor

@grlee77 grlee77 commented Jan 11, 2019

For some boundary modes and data sizes, round-trip DWT/IDWT can results in an output that has an additional coefficient. Here is a simple 1D example where roundtrip transform of a length 17 signal gives a length 18 output:
pywt.waverec(pywt.wavedec(np.arange(17), 'db3', level=3), 'db3').shape

There is some existing logic that seems intended to trim the extra coefficients during wavelet packet transforms:

data = super(WaveletPacket, self).reconstruct(update)
if self.data_size is not None and len(data) > self.data_size:
data = data[:self.data_size]

However, this really needs to be done at the Node rather than WaveletPacket level as indicated by the shape problem raised in #447.

closes #447

inverse transforms may produce excess coefficients for some sizes and boundary
modes. these need to be trimmed at the Node level as implemented here.
This commit fixes PyWavelets#447
trimming is now done at the Node level, so this is redundant.
@grlee77 grlee77 added the bug label Jan 11, 2019
@rgommers rgommers added this to the v1.1 milestone Feb 4, 2019
@grlee77 grlee77 changed the title Fix: properly trim wavelet packet node coefficients during reconstruction Properly trim wavelet packet node coefficients during reconstruction Feb 11, 2019
@grlee77
Copy link
Contributor Author

grlee77 commented Feb 13, 2019

I made the change data_shape -> _data_shape. If this looks good to go, please merge and then I will backport it to 1.0.x.

We will probably then be ready to do a new maintenance release from that branch.

@rgommers rgommers merged commit dbdd4be into PyWavelets:master Feb 14, 2019
@rgommers
Copy link
Member

Thanks @grlee77, looks good to me, merged

grlee77 added a commit that referenced this pull request Feb 15, 2019
backport of #448 (fix coefficient shape mismatch in WaveletPacket reconstruction)
@grlee77 grlee77 deleted the wp_size_fix branch November 13, 2019 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue using pywt.WaveletPacket2D

2 participants