-
Notifications
You must be signed in to change notification settings - Fork 90
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
fix: structure removal order for unions #3397
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e4dc991
fix: order of structure removal for unions
pfackeldey 8e2375c
add test
pfackeldey f3f675f
use index_nplike of tags instead of global numpy nplike
pfackeldey f7a66e4
fix: order of structure removal for unions
pfackeldey cc6a6e5
add test
pfackeldey d8b66f9
use index_nplike of tags instead of global numpy nplike
pfackeldey bc105ff
fix recursive structure removal logic
ianna d5b2d9c
add failing test
ianna 41cc923
add one more test
ianna c4d4330
Merge branch 'main' into pfackeldey/fix_ravel_order_uniontags
pfackeldey a197211
Merge branch 'pfackeldey/fix_ravel_order_uniontags' of github.com:sci…
pfackeldey 6e541ae
make new union array raveling work with typetracing
pfackeldey e22f43a
Merge branch 'main' into pfackeldey/fix_ravel_order_uniontags
ianna 9c5fd76
Merge branch 'main' into pfackeldey/fix_ravel_order_uniontags
ianna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE | ||
# ruff: noqa: E402 | ||
|
||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
import awkward as ak | ||
|
||
|
||
def test_ravel_boolean(): | ||
x = ak.Array([None, [False], [True]]) | ||
y = ak.ravel(ak.fill_none(x, False, axis=0)) | ||
assert y.tolist() == [False, False, True] | ||
|
||
|
||
def test_ravel_boolean_typetracer(): | ||
x = ak.Array([None, [False], [True]], backend="typetracer") | ||
y = ak.ravel(ak.fill_none(x, False, axis=0)) | ||
assert y.typestr == "## * bool" | ||
|
||
|
||
def test_ravel_ListOffsetArray(): | ||
a = ak.Array([[1, 2, 3], 4, [5, 6], 7, 8]) | ||
b = ak.ravel(a) | ||
assert b.tolist() == [1, 2, 3, 4, 5, 6, 7, 8] | ||
|
||
|
||
def test_ravel_ListOffsetArray_typetracer(): | ||
a = ak.Array([[1, 2, 3], 4, [5, 6], 7, 8], backend="typetracer") | ||
b = ak.ravel(a) | ||
assert b.typestr == "## * int64" | ||
|
||
|
||
def test_ravel_nested_ListOffsetArrays(): | ||
a = ak.Array([[[1, 2], 3], 4, [5, [[[6]]]], 7, 8]) | ||
b = ak.ravel(a) | ||
assert b.tolist() == [1, 2, 3, 4, 5, 6, 7, 8] | ||
|
||
|
||
def test_ravel_nested_ListOffsetArrays_typetracer(): | ||
a = ak.Array([[[1, 2], 3], 4, [5, [[[6]]]], 7, 8], backend="typetracer") | ||
b = ak.ravel(a) | ||
assert b.typestr == "## * int64" | ||
|
||
|
||
def test_ravel_incompatible_contents(): | ||
a = ak.Array([1, "high", 2, "low"]) | ||
with pytest.raises( | ||
AssertionError, | ||
match="cannot merge NumpyArray with ListOffsetArray", | ||
): | ||
ak.ravel(a) | ||
|
||
|
||
def test_ravel_incompatible_contents_typetracer(): | ||
a = ak.Array([1, "high", 2, "low"], backend="typetracer") | ||
with pytest.raises( | ||
AssertionError, | ||
match="cannot merge NumpyArray with ListOffsetArray", | ||
): | ||
ak.ravel(a) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pfackeldey this is a correct solution as far as structure goes, although allocates repeatedly according to the tags which is not ideal.
Would you be able to leave a
# FIXME:
note here (probably just commit tomain
) that we can optimise this by building aUnionArray
over the original naive loop to re-order the result? That might not be trivial to do, but we should definitely remark upon it!