BUG: fix indexing in reconstruct method of 1-D/2-D wavelet packet - #860
Open
rgommers wants to merge 3 commits into
Open
BUG: fix indexing in reconstruct method of 1-D/2-D wavelet packet #860rgommers wants to merge 3 commits into
reconstruct method of 1-D/2-D wavelet packet #860rgommers wants to merge 3 commits into
Conversation
Every existing WaveletPacketND test uses even-length axes, so the trim back to the original data shape was never exercised - which is how the IndexError in reconstruct() went unnoticed.
… shape Node._reconstruct and Node2D._reconstruct both trim the inverse transform back to the shape of the coefficients stored in the node, but NodeND._reconstruct did not. For odd-length axes this made a subnode reconstruct one sample too long along each transformed axis, and with update=True the data held by the node silently grew. It is also why only the ND class reached the trim in WaveletPacketND.reconstruct, where the IndexError was hit.
Same defect as the one fixed in WaveletPacketND.reconstruct: numpy no longer accepts a list of slices as an index. These two are not reachable today, as the node level trim in Node._reconstruct and Node2D._reconstruct already resizes the data, so there is nothing to add a test for.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a follow-up to gh-857, fixing the same issue for 1-D/2-D as that PR fixed for n-D. Also improve the tests.
AI usage declaration: I used Claude Opus 5.0 to audit the code for this issue, and most of the code is generated by it.