You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The behavior would follow from the usual rules if the index were integral, but it's not obvious to me that this should work for a boolean index of zero size. Indeed, PyTorch fails with:
IndexError: The shape of the mask [0] at index 0 does not match the shape of the indexed tensor [3] at index 0
and dask.array fails with:
ValueError: operands could not be broadcast together with shapes (3,) (0,)
If the NumPy behavior is desired, does it follow from the usual rule, or is it a special case? Either way, it would help to spell out the desired behavior to ensure consistency among backends.
The text was updated successfully, but these errors were encountered:
Not sure where the zero rule comes from, although maybe I am forgetting somthing? I suspect it drops out of the special case to make empty lists work and is strictly incorrect for boolean arrays.
FWIW, I consider it a NumPy bug to allow this, although it may make sense to deprecate rather than just remove it. (Length 0 simply isn't special.)
It has certainly no reason to exist here.
The standard seems to allow elements of a boolean index's shape to be zero.
But I have read a few times, and I don't think it specifies what should happen in this case.
This returns an empty array in NumPy, CuPy,
array_api_strict
, andjax.numpy
.The behavior would follow from the usual rules if the index were integral, but it's not obvious to me that this should work for a boolean index of zero size. Indeed, PyTorch fails with:
and
dask.array
fails with:If the NumPy behavior is desired, does it follow from the usual rule, or is it a special case? Either way, it would help to spell out the desired behavior to ensure consistency among backends.
The text was updated successfully, but these errors were encountered: