Skip to content

BUG: fix replace on non-contiguous array views#513

Merged
neutrinoceros merged 2 commits intopydata:masterfrom
emmanuel-ferdman:fix-replace-stride
Feb 5, 2026
Merged

BUG: fix replace on non-contiguous array views#513
neutrinoceros merged 2 commits intopydata:masterfrom
emmanuel-ferdman:fix-replace-stride

Conversation

@emmanuel-ferdman
Copy link
Contributor

PR Summary

When calling bn.replace on a non-contiguous view (e.g. array[::2] or a slice from a 3D array), not all matching values were replaced. The array indexing didn't account for stride, so it accessed wrong memory locations. This restores the fix from PR #295 which was accidentally reverted in the commit bcf5aa9.

Fixes #496.

Copy link
Collaborator

@neutrinoceros neutrinoceros left a comment

Choose a reason for hiding this comment

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

the fix seems correct to me. Thanks a lot ! I would suggest tightening the first test case while we're at it.

Copy link
Collaborator

@neutrinoceros neutrinoceros left a comment

Choose a reason for hiding this comment

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

thank you !

@neutrinoceros neutrinoceros merged commit b523901 into pydata:master Feb 5, 2026
35 checks passed
@rgommers rgommers added this to the 1.7.0 milestone Feb 5, 2026
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] replace gives incomplete result on non-contiguous view

3 participants