Skip to content

BUG: use same-kind casting for the np.searchsorted sorter argument - #32668

Merged
seberg merged 4 commits into
numpy:mainfrom
ikrommyd:fix-searchsorted-sorter-intp-same-kind-casting
Sep 18, 2026
Merged

seberg merged 4 commits into
numpy:mainfrom
ikrommyd:fix-searchsorted-sorter-intp-same-kind-casting

Conversation

@ikrommyd

@ikrommyd ikrommyd commented Sep 16, 2026

Copy link
Copy Markdown
Member

PR summary

np.searchsorted now casts sorter with same-kind casting, following #26610 (np.take) and #28355 (np.bincount). Integer arrays such as uint64, or int64 on 32-bit platforms, now work.
Same problem as #4384, for np.searchsorted.

AI Disclosure

An AI model was used to investigate the history of the issue and draft the changes.

Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
…onversion

Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
Signed-off-by: Iason Krommydas <iason.krom@gmail.com>

@mattip mattip left a comment

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.

Like #32667, LGTM. @seberg would you like to take a look?

@ikrommyd

Copy link
Copy Markdown
Member Author

The wheel bulder is a failure to upload artifacts after building so not related to the PR.

@seberg seberg left a comment

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.

Yap, agreed, thanks Iason!

Comment thread numpy/_core/src/multiarray/item_selection.c
Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
@ikrommyd

Copy link
Copy Markdown
Member Author

These 4 PRs that I'm doing about same-kind casting are not backport candidates right? I guess it wouldn't be nice to relax casting in a patch release.

@seberg

seberg commented Sep 18, 2026

Copy link
Copy Markdown
Member

Hmmmm, no very strong opinion either way for these. My take: the need for backport is only that someone could be hitting this while working on support NumPy 2+ (which is still a real possibility, NumPy was ~2.5 years ago).
(And yes, I have been saying 👍 to backports more often than I should based on this recently, I suspect.)

To nudge against (for behavior fixes in general):

  • 3 months is not a long time!
  • Even obvious, real, fixes like this can cause CI fallout down-stream and while that is all easy, there is always overhead/annoyance.
  • Errors are always plausible and even if confident, I am not sure if it isn't useful.
  • Not sure, but it may be nice if bug-fix diffs are easily reviewed. That argues for trying to keep them slim.

My point is: Any pins like numpy<=2.5.2 added after a patch release broke someone is a bad pin.

@seberg
seberg merged commit e765e67 into numpy:main Sep 18, 2026
91 checks passed
@ikrommyd
ikrommyd deleted the fix-searchsorted-sorter-intp-same-kind-casting branch September 18, 2026 08:50
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.

3 participants