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

ak.concatenate with axis=1 fails for more than 127 regular-length arrays #3310

Closed
jpivarski opened this issue Nov 20, 2024 · 1 comment · Fixed by #3312
Closed

ak.concatenate with axis=1 fails for more than 127 regular-length arrays #3310

jpivarski opened this issue Nov 20, 2024 · 1 comment · Fixed by #3312
Assignees
Labels
bug The problem described is something that must be fixed

Comments

@jpivarski
Copy link
Member

Version of Awkward Array

HEAD

Description and code to reproduce

>>> ak.concatenate([ak.Array([i])[:, np.newaxis] for i in range(127)], axis=1)
<Array [[0, 1, 2, 3, 4, ..., 122, 123, 124, 125, 126]] type='1 * 127 * int64'>

but

>>> ak.concatenate([ak.Array([i])[:, np.newaxis] for i in range(128)], axis=1)
Traceback (most recent call last):
...
KeyError: ('awkward_UnionArray_regular_index_getsize', <class 'numpy.int64'>, <class 'numpy.int64'>)

This error occurred while calling

    ak.concatenate(
        [<Array [[0]] type='1 * 1 * int64'>, <Array [[1]] type='1 * 1 * int64...
        axis = 1
    )
@jpivarski jpivarski added the bug The problem described is something that must be fixed label Nov 20, 2024
@jpivarski
Copy link
Member Author

ak.concatenate is going into UnionArray here:

index = ak.contents.UnionArray.regular_index(tags, backend=backend)

which is part of this if-condition:

if all(
(isinstance(x, ak.contents.Content) and x.is_regular)
or (isinstance(x, ak.contents.NumpyArray) and x.data.ndim > 1)
or not isinstance(x, ak.contents.Content)
for x in inputs
):

Note the x.is_regular. If the array were not regular, then we don't hit the bug:

>>> ak.concatenate([ak.Array([[i]]) for i in range(128)], axis=1)
<Array [[0, 1, 2, 3, 4, ..., 123, 124, 125, 126, 127]] type='1 * var * int64'>
>>> ak.concatenate([ak.Array([[i]]) for i in range(129)], axis=1)
<Array [[0, 1, 2, 3, 4, ..., 124, 125, 126, 127, 128]] type='1 * var * int64'>

I think #3207 handled the variable-length list case but not the regular-length list case.

@jpivarski jpivarski changed the title ak.concatenate with axis=1 fails for more than 127 arrays ak.concatenate with axis=1 fails for more than 127 regular-length arrays Nov 20, 2024
@ianna ianna self-assigned this Nov 20, 2024
@ianna ianna linked a pull request Nov 21, 2024 that will close this issue
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