-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 2881 akconcatenate fails trying to concatenate too many nested a…
…rrays (#3207) To resolve this we allow `UnionArray.nested_tags_index` and `UnionArray.simplified` to handle incoming tags with type Index64. Resulting, simplified UnionArrays are still limited to 128 distinct types/tags, but this limitation is much less likely to create limitations in practice. * New approach: add partial support for 64-bit tags Expanding the template instances for: * awkward_UnionArray_nestedfill_tags_index * awkward_UnionArray_simplify_one * awkward_UnionArray_simplify These allow 64-bit tags in certain cases, for ak_concatenate. * Ordering specializations in kernel-specification.yml * UnionArray.simplify length tests moved. Also a few style modifications. The reason for moving those length checks is so that I do not wish even temporarily hold on to content tags with invalid data. * Reverting change to batch index in ak_concatenate Co-authored-by: Jim Pivarski <[email protected]> --------- Co-authored-by: Jim Pivarski <[email protected]>
- Loading branch information
1 parent
3ab54f8
commit af232f5
Showing
7 changed files
with
153 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tests/test_2881_ak_concatenate_fails_on_too_many_nested_arrays.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE | ||
|
||
from __future__ import annotations | ||
|
||
import awkward as ak | ||
|
||
# from awkward.operations import to_list | ||
|
||
|
||
def test_concatenate_as_reported(): | ||
a = ak.Array([[1]]) | ||
a_concat_128 = ak.concatenate([a for i in range(128)], axis=1) | ||
assert a_concat_128.to_list() == [[1] * 128] | ||
|
||
a_concat_129 = ak.concatenate([a for i in range(129)], axis=1) | ||
assert a_concat_129.to_list() == [[1] * 129] | ||
|
||
|
||
def test_concatenate_inner_union_simplify_one(): | ||
a = ak.Array([[99]]) | ||
astr = ak.Array(["a b c d".split()]) | ||
aa = [a for i in range(129)] + [astr] | ||
|
||
cu = ak.concatenate(aa, axis=1) | ||
assert cu.to_list() == [[99] * 129 + ["a", "b", "c", "d"]] | ||
|
||
|
||
def test_concatenate_inner_union_simplify(): | ||
a = ak.Array([[99]]) | ||
amulti = ak.Array([[1, 2, "a", "b"]]) | ||
aa = [a for i in range(129)] + [amulti] | ||
|
||
cu = ak.concatenate(aa, axis=1) | ||
assert cu.to_list() == [[99] * 129 + [1, 2, "a", "b"]] |