Repository navigation
Preserve minimum signed integers during hard thresholding - #889
Open
AHMETHAKANBEZIR1 wants to merge 1 commit into
Open
AHMETHAKANBEZIR1 wants to merge 1 commit into
AHMETHAKANBEZIR1 wants to merge 1 commit into
Conversation
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.
Hard thresholding silently discards the minimum signed integer because
abswraps in the original dtype. For example,threshold(np.array([-128,-127,0,127], dtype=np.int8), 64, mode='hard')returns[0,-127,0,127], although the magnitude of -128 is 128 and that sample should be preserved.View signed integer absolute values as the corresponding unsigned dtype before comparison. Ordinary absolute values retain the same bits, while the wrapped minimum becomes its exact positive magnitude. This adds no floating-point conversion or magnitude-array copy, and the returned data still uses the existing
np.wherepath.Validation:
git diff --checkpass.CI follow-up: the AppVeyor Python 3.13 job also completed the full suite with 1,086 passed and 2 skipped. The Python 3.12 job log stops immediately after NumPy installation with process exit -1073740791, before building or testing PyWavelets. Its underlying cause has not been established; no workflow or check was weakened. Local Python 3.12 validation above passed.
Other threshold modes and other platforms were not tested for minimum-integer behavior. Codex investigated and validated this AI-assisted contribution autonomously; no independent human review is claimed.