Skip to content

[Bug]: Indexing with 0-dimensional key #1019

@neosunhan

Description

@neosunhan

What happened?

Indexing a DNDarray with a 0-dimensional DNDarray as a key throws an error.

Code snippet triggering the error

>>> import heat as ht
>>> import numpy as np
>>> np.array(False)[np.array(False)]
array([], dtype=bool)
>>> ht.array(False)[ht.array(False)]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../heat/core/dndarray.py", line 755, in __getitem__
    if self.__key_adds_dimension(key, i, self_proxy):
  File ".../heat/core/dndarray.py", line 968, in __key_adds_dimension
    return self_proxy[(*zeros[:axis], key[axis], *zeros[axis:])].ndim == 2
IndexError: too many indices for tensor of dimension 0

Version

main (development branch)

Python version

3.10

PyTorch version

1.11

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

Status
In Progress

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions