-
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: remove unneeded cast * test: ensure slice behaves properly * test: explicitly set dtypes
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
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,44 @@ | ||
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE | ||
|
||
import numpy as np | ||
import pytest # noqa: F401 | ||
|
||
import awkward as ak | ||
|
||
|
||
def test(): | ||
layout = ak.contents.RecordArray( | ||
[ | ||
ak.contents.ListOffsetArray( | ||
ak.index.Index64([0, 3]), | ||
ak.contents.NumpyArray(np.array([1, 2, 3], dtype=np.uint16)), | ||
), | ||
ak.contents.ListOffsetArray( | ||
ak.index.Index64([0, 2]), | ||
ak.contents.NumpyArray(np.array([4, 5], dtype=np.uint16)), | ||
), | ||
], | ||
["x", "y"], | ||
) | ||
sliced = layout[..., np.newaxis] | ||
assert sliced.is_equal_to( | ||
ak.contents.RecordArray( | ||
[ | ||
ak.contents.RegularArray( | ||
ak.contents.ListOffsetArray( | ||
ak.index.Index64([0, 3]), | ||
ak.contents.NumpyArray(np.array([1, 2, 3], dtype=np.uint16)), | ||
), | ||
1, | ||
), | ||
ak.contents.RegularArray( | ||
ak.contents.ListOffsetArray( | ||
ak.index.Index64([0, 2]), | ||
ak.contents.NumpyArray(np.array([4, 5], dtype=np.uint16)), | ||
), | ||
1, | ||
), | ||
], | ||
["x", "y"], | ||
) | ||
) |