Skip to content

Update guidance for unsigned integer data types for sum and prod #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2021

Conversation

kgryte
Copy link
Contributor

@kgryte kgryte commented Nov 29, 2021

This PR

  • updates the guidance for sum and prod when x has an unsigned integer data type with a smaller range of values than the default integer data type and the dtype kwarg is None. Namely, when providing a uint8 array, the returned array should have a uint32 data type when the default integer data type is int32. This is in contrast to current guidance which requires that the returned array have an int32 data type. In short, the returned array should have a data type whose "signedness" matches the input array. Returning a signed integer array when providing an unsigned integer array is likely to violate user expectations.

The changes introduced in this PR match NumPy's current behavior.

@kgryte kgryte added API change Changes to existing functions or objects in the API. topic: Statistics Statistics. labels Nov 29, 2021
@kgryte kgryte added this to the v2021 milestone Nov 29, 2021
Copy link
Member

@honno honno left a comment

Choose a reason for hiding this comment

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

LGTM

@kgryte
Copy link
Contributor Author

kgryte commented Nov 29, 2021

Thanks for reviewing, @honno!

Will merge, as this was an initial oversight and aligns with current NumPy behavior and thus with established precedent.

@kgryte kgryte merged commit 11a3d2c into main Nov 29, 2021
@kgryte kgryte deleted the sum-prod-unsigned-ints branch November 29, 2021 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API change Changes to existing functions or objects in the API. topic: Statistics Statistics.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants