GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BUG: safer bincount casting (backport to 2.2.x) by jakirkham · Pull Request #28420 · numpy/numpy

Conversation

@jakirkham

@jakirkham jakirkham commented Mar 3, 2025

Copy link
Copy Markdown
Contributor

Backport of PR ( #28355 ) to 2.2.x

cc @tylerjereddy @seberg @charris

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tylerjereddy @seberg @jakirkham
BUG: safer bincount casting (numpy#28355)
1efec00
* BUG: safer bincount casting

* Fixes numpy#28354

* Force usage of `npy_intp` type in `np.bincount()` and avoid
unsafe casting errors with i.e., `npy_uint64`. This is similar
to our behavior with indexing.

* MAINT, BUG: PR 28355 revisions

* `arr_bincount()` now only uses unsafe casting for integer
input types, and the number of casting operations has
been reduced for the code path used in above PR.

* a test for non-crashing behavior with non-contiguous
`bincount()` input has been added.

* MAINT, BUG: PR 28355 revisions

* Based on reviewer feedback, narrow the scope of the `flags`
variable in `arr_bincount()`.

* Based on reviewer feedback, add an array-like test for the `uint64`
casting issue, which indeed fails before and passes after adding
a similar shim to the array-like code path in `arr_bincount()`.

* Based on reviewer feedback, switch the patching from `PyArray_Size`
to `PyArray_Check` in a few places.

* Update numpy/_core/src/multiarray/compiled_base.c

---------

Co-authored-by: Sebastian Berg <[email protected]>
@github-actions github-actions Bot added the 00 - Bug label Mar 3, 2025
@jakirkham jakirkham mentioned this pull request Mar 3, 2025
BUG: safer bincount casting #28355
Merged
@jorenham jorenham added the 08 - Backport Used to tag backport PRs label Mar 3, 2025
@charris charris added this to the 2.2.4 release milestone Mar 3, 2025
@charris
charris merged commit a9d3796 into numpy:maintenance/2.2.x Mar 3, 2025
@charris

charris commented Mar 3, 2025

Copy link
Copy Markdown
Member

Thanks @jakirkham .

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jakirkham
jakirkham deleted the backport_treddy_issue_28354_2.2.x branch March 3, 2025 21:49
@jakirkham

jakirkham commented Mar 3, 2025

Copy link
Copy Markdown
Contributor Author

Thanks Chuck! 🙏

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nschloe nschloe mentioned this pull request Apr 30, 2026
BUG, ENH: make bincount work with uint64 #17760
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

00 - Bug 08 - Backport Used to tag backport PRs

Projects

None yet

Milestone

2.2.4 release

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@jakirkham @charris @jorenham @tylerjereddy
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.