Skip to content

BUG: Fix incorrect behavior with unsigned int in np.unwrap (#29477) #29507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

devmt04
Copy link

@devmt04 devmt04 commented Aug 5, 2025

BUG-FIX : #29477

Previously, np.unwrap gave incorrect results when passed unsigned integer arrays, due to how np.diff handles unsigned inputs. This fix casts the input to a larger signed integer type before applying np.diff.

Previously:

In [4]: x1 = np.array([5, 1], dtype=np.uint64)
In [5]: np.unwrap(x1)
Out[5]: array([ 5.00000000e+00, -1.84467441e+19]) # Not Expected

After this fix:

In [2]: x1 = np.array([5, 1], dtype=np.uint64)
In [3]: np.unwrap(x1)
Out[3]: array([5.        , 7.28318531])

Closes #29477

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Awaiting a code review
Development

Successfully merging this pull request may close these issues.

BUG: numpy.unwrap Incorrect Behavior on Unsigned Integer Inputs
1 participant