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

Skip to content

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

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

Closed
eric-wieser opened this issue Mar 28, 2017 · 1 comment · Fixed by #8952
Closed

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

eric-wieser opened this issue Mar 28, 2017 · 1 comment · Fixed by #8952

Comments

@eric-wieser
Copy link
Member

eric-wieser commented Mar 28, 2017

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) 
@eric-wieser
Copy link
Member Author

eric-wieser commented Mar 28, 2017

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

eric-wieser added a commit to eric-wieser/numpy that referenced this issue Apr 17, 2017
There didn't seem to be any value to a `assign_identity` function - all we
actually care about is the value to assign.

This also fixes numpy#8860 as a side-effect, and paves the way for:

* easily adding more values (numpy#7702)
* using the identity in more places (numpy#834)
eric-wieser added a commit to eric-wieser/numpy that referenced this issue Oct 3, 2017
There didn't seem to be any value to a `assign_identity` function - all we
actually care about is the value to assign.

This also fixes numpy#8860 as a side-effect, and paves the way for:

* easily adding more values (numpy#7702)
* using the identity in more places (numpy#834)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant