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

Regular indexing behaves like jagged index for RegularArray (v2) #1358

Closed
agoose77 opened this issue Mar 9, 2022 · 2 comments · Fixed by #1943
Closed

Regular indexing behaves like jagged index for RegularArray (v2) #1358

agoose77 opened this issue Mar 9, 2022 · 2 comments · Fixed by #1943
Assignees
Labels
bug The problem described is something that must be fixed

Comments

@agoose77
Copy link
Collaborator

agoose77 commented Mar 9, 2022

Version of Awkward Array

c2ddda2

Description and code to reproduce

>>> array = ak.from_numpy(np.arange(4 * 4).reshape(4, 4))
>>> array[array > 4].ndim
2
>>> (array > 4).layout.purelist_isregular
True
>>> array[ak.to_numpy(array > 4)].ndim
1

Cause

The NumPy-like indexing checks for NumpyArray, not RegularArray. We should use something like maybe_toNumpyArray beforehand to fulfil this.

@agoose77 agoose77 added bug (unverified) The problem described would be a bug, but needs to be triaged bug The problem described is something that must be fixed and removed bug (unverified) The problem described would be a bug, but needs to be triaged labels Mar 9, 2022
@agoose77 agoose77 self-assigned this Sep 24, 2022
@agoose77 agoose77 removed their assignment Oct 6, 2022
@jpivarski jpivarski added the pr-next-release Required for the next release label Oct 31, 2022
@agoose77
Copy link
Collaborator Author

agoose77 commented Dec 3, 2022

What should array[EmptyArray()] return? Currently it is returning a NumpyArray with int64. This seems wrong to me, but there is no clear idea of what would be right. Maybe this should be an error?

@jpivarski
Copy link
Member

array[[]]

should interpret the typeless list as though it were an array of integers, and the return value would be an empty array with the same type as array.

If the slicer has a type, then we use that: boolean, integers, strings.

@jpivarski jpivarski removed the pr-next-release Required for the next release label Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The problem described is something that must be fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants