Skip to content

BUG: count_nonzero(axis=()) is inconsistent #9728

Closed

Description

@eric-wieser

A reasonable mental model for count_nonzero is (x != 0).sum(...). But if fails in this case:

>>> x = np.arange(3)
>>> (x != 0).sum(axis=())
array([0, 1, 1])
>>> np.count_nonzero(x != 0, axis=())
2

axis == () should mean (x == 0).astype(int)

Activity

  1. added a commit that references this issue on Oct 18, 2017
    3856a73
  2. added a commit that references this issue on Oct 23, 2017
    6ec2d71
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions