Skip to content

BUG: ufunc.reduce(ndarray(dtype=object)) returns bool #8860

Closed

Description

@eric-wieser

This is pretty weird:

>>> arr = np.array([1, 2, 3], dtype=object)
>>> np.add.reduce(arr)
6
>>> np.add.reduce(arr[:0])
False
>>> np.multiply.reduce(arr)
6
>>> np.multiply.reduce(arr[:0])
True

It happens for array results too:

>>> arr = np.array([[1], [2], [3]], dtype=object)
>>> np.add.reduce(arr[:0], axis=0)
array([False], dtype=object)
>>> np.multiply.reduce(arr[:0], axis=0)
array([True], dtype=object) 

Activity

  1. eric-wieser commented on Mar 28, 2017

    @eric-wieser
    MemberAuthor

    The underlying problem is that the identity of reductions has to be the same for all loop types, and so for .all and .any to work, it needs to be a bool

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