Skip to content

Raise an IndexError when array index is not integer #1785

@vtavana

Description

@vtavana

When index of an array is a floaing point number, NumPy raises an IndexError while dpctl returns an incorrect result.

>>> import numpy, dpctl, dpctl.tensor as dpt
>>> dpctl.__version__
'0.18.0dev0+235.gd79dae1d2f'

>>> numpy.__version__
'1.26.4'

>>> b=dpt.asarray([1+1j, 2+2j])
>>> b[0.].imag
usm_ndarray([])
 
>>> b[1.].imag
usm_ndarray([[1., 2.]])
 
>>> a=numpy.array([1+1j, 2+2j])
>>> a[0.].imag
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
 
>>> a[1.].imag
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions