Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Slice error when array contains an axis of length 0 #1012

Closed
neosunhan opened this issue Aug 21, 2022 · 4 comments
Closed

[Bug]: Slice error when array contains an axis of length 0 #1012

neosunhan opened this issue Aug 21, 2022 · 4 comments
Assignees
Labels
bug Something isn't working dndarray GSoC stale

Comments

@neosunhan
Copy link
Collaborator

neosunhan commented Aug 21, 2022

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

@neosunhan neosunhan added bug Something isn't working GSoC dndarray labels Aug 21, 2022
@neosunhan neosunhan self-assigned this Aug 21, 2022
@ClaudiaComito
Copy link
Contributor

ongoing work in #938

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2023

Copy link
Contributor

This issue is stale because it has been open for 60 days with no activity.

@github-actions github-actions bot added the stale label May 20, 2024
Copy link
Contributor

This issue was closed because it has been inactive for 60 days since being marked as stale.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dndarray GSoC stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants