Skip to content

Allow Python integer return for count_nonzero(arr, axis=None) #932

Open
@seberg

Description

@seberg

NumPy returns Python integers in that particular case, and I am not sure I feel it's worth changing it.

The reason is, that if a place only uses axis=None (the default), the result of intp vs. Python integer, changes promotion rules when combined with e.g. float32.

Now, I don't think this will happen a lot, but for count_nonzeros I am not sure I don't think this isn't more user-friendly and an OK and very small inconsistency.
NumPy itself will be fine (because we never only use axis=None), skimage I saw one function which would return float64 rather than a Python float.

(Maybe one of those things where, I feel forcing intp return is great, but I am not sure changing NumPy main namespace for it is worthwhile.)

See numpy/numpy#28615 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    API changeChanges to existing functions or objects in the API.Needs DiscussionNeeds further discussion.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions