Conversation
Handle x[True] and x[False] as NumPy does, even though the behavior may be undocumented. NumPy treats True as None (insert axis with size 1), and treats False as None followed by empty slicing (insert axis with size 0). Changed the logic of _basic_slice_meta utility function to correctly handle boolean scalars (surprisingly, `insinstance(True, int)` evaluates to `True`). 0d arrays are handled by Python scalars. Introduced _is_integral and _is_boolean utilty functions and used them in `_basic_slice_meta` utility.
|
View rendered docs @ https://intelpython.github.io/dpctl/pulls/1136/index.html |
|
Array API standard conformance tests for dpctl=0.14.3dev0=py310h76be34b_21 ran successfully. |
|
The below example works differently with numpy: |
|
Actually this behavior in NumPy is undocumented and we should not rely on it: https://stackoverflow.com/questions/75828008/docs-about-boolean-scalars-in-indexing-of-numpy-array I will change the implementation to raise |
|
Ok, in that case, I am inclined to leave things as is. The behavior of |
|
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞 |
|
Array API standard conformance tests for dpctl=0.14.3dev0=py310h76be34b_21 ran successfully. |
Closes gh-1135.
Handle
x[True]andx[False]as NumPy does, even though the behaviormay be undocumented. NumPy treats
TrueasNone(insert axis with size 1),and treats
FalseasNonefollowed by empty slicing (insert axis with size 0).Changed the logic of
_basic_slice_metautility function to correctly handleboolean scalars (surprisingly,
insinstance(True, int)evaluates toTrue).0d arrays are handled on the same footing as the Python scalars.
Introduced
_is_integraland_is_booleanutilty functions and used them in_basic_slice_metautility.