Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BUG: Fix unwrap function for object arrays with large numbers.#28911

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
sim0es wants to merge2 commits intonumpy:main
base:main
Choose a base branch
Loading
fromsim0es:unwrap-edgecase

Conversation

sim0es
Copy link

Implemented special handling for object arrays in np.unwrap to correctly unwrap sequences containing very large numbers (e.g., >10^50). The fix properly implements period-based unwrapping logic for object arrays, ensuring consistent increments that respect the specified period parameter.Fixes#27686.

Implemented special handling for object arrays in np.unwrap to correctly unwrap sequences containing very large numbers (e.g., >10^50).The fix properly implements period-based unwrapping logic for object arrays, ensuring consistent increments that respect the specified period parameter.Fixesnumpy#27686.
dd = diff(p, axis=axis)

if p.dtype == np.object_:
initial_value = p[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What ifp is empty? Orp is a 2D array?

Copy link
Author

@sim0essim0esMay 12, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

the function should work properly ifp is empty or a 2D array. my changes only affected the case wherep is an object

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What happens fornp.unwrap(np.array([], dtype=object))?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

you're right. it gives meIndexError: index 0 is out of bounds for axis 0 with size 0. I'll work on a solution for this

initial_value = p[0]
unwrapped = [initial_value]
for val in p[1:]:
unwrapped.append(unwrapped[-1] + 1)
Copy link
Contributor

@eendebakpteendebakptMay 6, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Appending in a for loop will be much slower than the current implementation for larger arrays.

Do you know the root cause of the problem for bigints? Perhaps we can modify the algorithm at that point. I checked that the first step (e.g.np.diff(p, axis=axis)) works fine

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@eendebakpteendebakpteendebakpt left review comments

@ngoldbaumngoldbaumngoldbaum left review comments

Assignees
No one assigned
Labels
Projects
Status: Awaiting a code review
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

BUG: np.unwrap returns incorrect values for bigints
3 participants
@sim0es@eendebakpt@ngoldbaum

[8]ページ先頭

©2009-2025 Movatter.jp