fix: enforce consistent coefficient order for ravel_coeffs#427
Merged
Conversation
Contributor
Author
|
closes #426 |
This was referenced Sep 20, 2018
Closed
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.
The current implementation of
ravel_coeffsdepends on the order of the keys in the detail coefficient dictionaries returned bywavedecn. This order can vary across python versions due to differences in whether the underlying Python dict respects insertion order. This PR just sorts the keys first to make sure that the wavelet subbands are stacked in the raveled array is identical across all Python versions.A compact example of the key ordering issue:
The output of the print statement above in Python 3.6 is
dict_keys(['ad', 'da', 'dd']), but on Python 2.7 is['dd', 'ad', 'da']. Note the difference in order which ends up reflected in which order the coefficients are stacked bypywt.ravel_coeffs.print(sorted(c[1].keys())) whereas gives
['ad', 'da', 'dd']on both versions for consistent order.