Skip to content

Commit

Permalink
fix: proper typetracer array slicing in BitMaskedArray (#3028)
Browse files Browse the repository at this point in the history
* fix: proper typetracer array slicing in BitMaskedArray

* test: add test
  • Loading branch information
agoose77 authored Feb 20, 2024
1 parent 4706bdf commit 8b8bc73
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/awkward/contents/bitmaskedarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,9 @@ def mask_as_bool(self, valid_when=None):
self._lsb_order,
)
)
return bytemask.data[: self._length].view(np.bool_)
return bytemask.data[
: self._backend.index_nplike.shape_item_as_index(self._length)
].view(np.bool_)

def _getitem_nothing(self):
return self._content._getitem_range(0, 0)
Expand Down
19 changes: 19 additions & 0 deletions tests/test_3028_mask_bitmaskedarray.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from __future__ import annotations

import numpy as np

import awkward as ak
from awkward.typetracer import unknown_length


def test():
arr = (
ak.mask([1, 2, 3], [True, False, False], highlevel=False)
.to_BitMaskedArray(valid_when=True, lsb_order=True)
.to_typetracer(forget_length=True)
)

result = arr.mask_as_bool()
assert result.dtype == np.dtype("bool")
assert result.ndim == 1
assert result.size is unknown_length

0 comments on commit 8b8bc73

Please sign in to comment.