Skip to content

Commit

Permalink
fix: remove unneeded cast (#2653)
Browse files Browse the repository at this point in the history
* fix: remove unneeded cast

* test: ensure slice behaves properly

* test: explicitly set dtypes
  • Loading branch information
agoose77 authored Aug 16, 2023
1 parent 735a377 commit 61c3660
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/awkward/contents/listoffsetarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ def _getitem_next(
tail: tuple[SliceItem, ...],
advanced: Index | None,
) -> Content:
advanced = advanced.to_nplike(self._backend.nplike)
if head is NO_HEAD:
return self

Expand Down
44 changes: 44 additions & 0 deletions tests/test_2653_slice_listoffsetarray.py
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"],
)
)

0 comments on commit 61c3660

Please sign in to comment.