Skip to content

BUG: fancy indexing copy#26868

Merged
charris merged 1 commit into
numpy:maintenance/2.0.xfrom
charris:backport-26558
Jul 5, 2024
Merged

BUG: fancy indexing copy#26868
charris merged 1 commit into
numpy:maintenance/2.0.xfrom
charris:backport-26558

Conversation

@charris
Copy link
Copy Markdown
Member

@charris charris commented Jul 5, 2024

Backport of #26558.

  • BUG: fancy indexing copy

  • Fixes Fancy indexing fails on a[idx] = a #26542

  • For these very simple advanced indexing cases, if the result and self arrays share the same
    data pointers, use a copy of result to assign
    values to self, otherwise the outcome of the fancy indexing suffers from mutation of result before
    the assignments are complete.

  • MAINT, BUG: PR 26558 revisions

  • Avoid leaking the old tmp_arr, based on reviewer feedback.

  • Add a test for a similar 2D case that fails, then hoist solve_may_share_memory() check farther up in the control flow such that the test passes.

  • Add a reviewer-requested test for index overlap.

  • BUG: PR 26558 revisions

  • The usage of solve_may_share_memory in the above PR wasn't quite right since it ignored the case of failing to solve the overlap problem. This has been revised according to reviewer feedback.


* BUG: fancy indexing copy

* Fixes numpygh-26542

* For these very simple advanced indexing cases,
if the `result` and `self` arrays share the same
data pointers, use a copy of `result` to assign
values to `self`, otherwise the outcome of the fancy
indexing suffers from mutation of `result` before
the assignments are complete.

* MAINT, BUG: PR 26558 revisions

* Avoid leaking the old `tmp_arr`, based on reviewer feedback.

* Add a test for a similar 2D case that fails, then hoist
`solve_may_share_memory()` check farther up in the control
flow such that the test passes.

* Add a reviewer-requested test for index overlap.

* BUG: PR 26558 revisions

* The usage of `solve_may_share_memory` in the above
PR wasn't quite right since it ignored the case of failing
to solve the overlap problem. This has been revised according
to reviewer feedback.

Co-authored-by: Sebastian Berg <sebastianb@nvidia.com>

---------

Co-authored-by: Sebastian Berg <sebastianb@nvidia.com>
@charris charris added this to the 2.0.1 release milestone Jul 5, 2024
@charris charris merged commit c8c1e4e into numpy:maintenance/2.0.x Jul 5, 2024
@charris charris deleted the backport-26558 branch July 5, 2024 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants