FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

BUG: properly handle negative indexes in ufunc_at fast path by mattip · Pull Request #24150 · numpy/numpy · GitHub

/ numpy Public

BUG: properly handle negative indexes in ufunc_at fast path - #24150

Merged
charris merged 1 commit into
numpy:mainfrom
mattip:issue-24147
Jul 9, 2023
Merged

charris merged 1 commit into
numpy:mainfrom
mattip:issue-24147

Conversation

mattip commented Jul 9, 2023

Copy link
Copy Markdown
Member

Fixes #24147

When avoiding the iter API for faster iteration, negative indexes need to be unwrapped.

Other places this is done in a similar way:

Test added that failed before, passes after

mattip added the 09 - Backport-Candidate PRs tagged should be backported label Jul 9, 2023
charris merged commit c19ce9c into numpy:main Jul 9, 2023

charris commented Jul 9, 2023

Copy link
Copy Markdown
Member

Thanks Matti.

assert a[-1] == 11 # issue 24147
assert a[1] == 2
assert a[2] == 3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

An bad merge (locally) brought me here, but then I noticed that this can modify the original index array:

assert indxs[0] == -1

would fail. I think it shows that passing pointers or full offsets rather than indices makes more sense here (we need a temporary array anyway), but I have to think about how a hot-fix should look like.
Probably either need a local buffer here, or push the fixing into the indexed loop.

(Maybe local buffer is good, since that is what I would want to do with that hot-fix anyway in some form, even if it may make sense to push the buffer for that case slightly further up.)

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: (1.25.0) ufunc.at returns wrong results when indices is an array containing negative ints

3 participants


Back | FazBrowse Home | New Git URL