What happened?
On arrays where one of the dimensions is of size 0, adding an extra dimension via slicing with None results in an error.
Taking reference from numpy, this should instead add the extra dimension normally.
Code snippet triggering the error
>>> import heat as ht
>>> import numpy as np
>>> np_array = np.array([])
>>> ht_array = ht.array([])
>>> np_array.shape
(0,)
>>> ht_array.shape
(0,)
>>> np_array[None]
array([], shape=(1, 0), dtype=float64)
>>> ht_array[None]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../heat/core/dndarray.py", line 757, in __getitem__
return self.expand_dims(i)[tuple(key)]
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: index 0 is out of bounds for dimension 1 with size 0
Version
main (development branch)
Python version
3.10
PyTorch version
1.11
What happened?
On arrays where one of the dimensions is of size 0, adding an extra dimension via slicing with
Noneresults in an error.Taking reference from numpy, this should instead add the extra dimension normally.
Code snippet triggering the error
Version
main (development branch)
Python version
3.10
PyTorch version
1.11