Skip to content
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

Error raised in np.std with where argument #18623

Closed
gshoffner opened this issue Mar 15, 2021 · 1 comment
Closed

Error raised in np.std with where argument #18623

gshoffner opened this issue Mar 15, 2021 · 1 comment

Comments

@gshoffner
Copy link

An error is raised when invoking both the axis and where arguments in numpy.std for arrays of dimension greater than 2.

Reproducing code example:

import numpy as np
arr = np.arange(3*3*4).reshape(3,3,4)
res = np.std(arr, axis = 1, where = arr>5)

Error message:

Traceback (most recent call last):
File "", line 1, in
File "<array_function internals>", line 5, in std
File "/home/grant/.local/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 3560, in std
return _methods._std(a, axis=axis, dtype=dtype, out=out, ddof=ddof,
File "/home/grant/.local/lib/python3.8/site-packages/numpy/core/_methods.py", line 261, in _std
ret = _var(a, axis=axis, dtype=dtype, out=out, ddof=ddof,
File "/home/grant/.local/lib/python3.8/site-packages/numpy/core/_methods.py", line 200, in _var
if ddof >= rcount if where is True else umr_any(ddof >= rcount):
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

NumPy/Python version information:

1.20.1 3.8.5 (default, Jan 27 2021, 15:41:15)
[GCC 9.3.0]

@seberg
Copy link
Member

seberg commented Mar 15, 2021

Thanks for the report @gshoffner! This has been fixed on the development branch, and will be part of the 1.20.2 release. (see gh-18612).

@seberg seberg closed this as completed Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants