Thanks to visit codestin.com
Credit goes to github.com

Skip to content

any() for object-dtype arrays returns non-booleans #10489

@acdr000

Description

@acdr000

The any function seems to not deal well for arrays of dtype object. According to the documentation it should return a boolean. However, consider the following code:

print(numpy.array([5, None]).any())

To my surprise, this prints 5, rather than True. It seems to always return the first element of which the boolean value is True, or, if no such elements exist, the last element. (This means that numpy.array([False, None]).any() evaluates to None.)

Appears to happen in Python 3.6.1, Numpy 1.12.1, on Linux, as well as Python 2.7.10, numpy 1.9.2. on Windows (10).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions