BUG: threshold_firm returns shrunk value when the only large value is at index 0 - #883
Open
Arthur031221 wants to merge 1 commit into
Open
Arthur031221 wants to merge 1 commit into
Arthur031221 wants to merge 1 commit into
Conversation
…at index 0 The check np.any(large_vals[0]) tested index values for truthiness, so a value above value_high located at index 0 of the first axis was returned shrunk instead of unchanged. Use a boolean mask.
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.
threshold_firmreturns wrong values for anyone whose above-value_highentries all lie in the first row (for 1-D data, a single large value at index 0, such as a large approximation coefficient fromwavedec): those entries are shrunk instead of being left unchanged.The restore step used
np.any(large_vals[0]), which tests the index values fromnp.wherefor truthiness, so index 0 counts as "nothing to restore". It now indexes with the boolean maskmagnitude > value_high.Before:
After:
[5., 0.]for the first call. The second is unchanged.Added
test_threshold_firm_large_value_first(1-D, 2-D, complex); it fails on main and passes with the change. Full suite: 1053 passed, 2 skipped.