diff --git a/src/awkward/contents/content.py b/src/awkward/contents/content.py index 1a0fe080a9..d340ed039d 100644 --- a/src/awkward/contents/content.py +++ b/src/awkward/contents/content.py @@ -512,6 +512,8 @@ def __getitem__(self, where): return self._getitem(where) def _getitem(self, where): + print("\nContent::_getitem", self, where) # noqa: T201 + if is_integer_like(where): return self._getitem_at(ak._slicing.normalize_integer_like(where)) diff --git a/src/awkward/contents/listarray.py b/src/awkward/contents/listarray.py index 722b9044dd..4f8f5da9e6 100644 --- a/src/awkward/contents/listarray.py +++ b/src/awkward/contents/listarray.py @@ -307,6 +307,8 @@ def _is_getitem_at_placeholder(self) -> bool: ) def _getitem_at(self, where: IndexType): + print("\nListArray::_getitem_at", self, where) # noqa: T201 + if not self._backend.nplike.known_data: self._touch_data(recursive=False) return self._content._getitem_range(0, 0) @@ -319,6 +321,8 @@ def _getitem_at(self, where: IndexType): return self._content._getitem_range(start, stop) def _getitem_range(self, start: IndexType, stop: IndexType) -> Content: + print("\nListArray::_getitem_range", self, start, stop) # noqa: T201 + if not self._backend.nplike.known_data: self._touch_shape(recursive=False) return self @@ -351,6 +355,8 @@ def _getitem_fields( ) def _carry(self, carry: Index, allow_lazy: bool) -> Content: + print("\nListArray::_carry", self, carry, allow_lazy) # noqa: T201 + assert isinstance(carry, ak.index.Index) try: @@ -446,6 +452,14 @@ def _broadcast_tooffsets64(self, offsets: Index) -> ListOffsetArray: def _getitem_next_jagged( self, slicestarts: Index, slicestops: Index, slicecontent: Content, tail ) -> Content: + print( # noqa: T201 + "\nListArray::_getitem_next_jagged", + self, + slicestarts, + slicestops, + slicecontent, + ) + slicestarts = slicestarts.to_nplike(self._backend.index_nplike) slicestops = slicestops.to_nplike(self._backend.index_nplike) if self._backend.nplike.known_data and slicestarts.length != self.length: @@ -704,6 +718,8 @@ def _getitem_next( tail: tuple[SliceItem, ...], advanced: Index | None, ) -> Content: + print("\nListArray::_getitem_next", self, head, tail, advanced) # noqa: T201 + if head is NO_HEAD: return self @@ -712,6 +728,9 @@ def _getitem_next( nexthead, nexttail = ak._slicing.head_tail(tail) lenstarts = self._starts.length nextcarry = ak.index.Index64.empty(lenstarts, self._backend.index_nplike) + print(f" {lenstarts = }") # noqa: T201 + print(f" {self._starts = }") # noqa: T201 + print(f" {self._stops = }") # noqa: T201 assert ( nextcarry.nplike is self._backend.index_nplike and self._starts.nplike is self._backend.index_nplike @@ -732,6 +751,7 @@ def _getitem_next( ), slicer=head, ) + print(f" {nextcarry = }") # noqa: T201 nextcontent = self._content._carry(nextcarry, True) return nextcontent._getitem_next(nexthead, nexttail, advanced) diff --git a/src/awkward/contents/listoffsetarray.py b/src/awkward/contents/listoffsetarray.py index 4aa149b69d..8c295fd95e 100644 --- a/src/awkward/contents/listoffsetarray.py +++ b/src/awkward/contents/listoffsetarray.py @@ -304,6 +304,8 @@ def _is_getitem_at_placeholder(self) -> bool: return isinstance(self._offsets, PlaceholderArray) def _getitem_at(self, where: IndexType): + print("\nListOffsetArray::_getitem_at", self, where) # noqa: T201 + # Wrap `where` by length if not is_unknown_scalar(where) and where < 0: length_index = self._backend.index_nplike.shape_item_as_index(self.length) @@ -319,6 +321,8 @@ def _getitem_at(self, where: IndexType): return self._content._getitem_range(start, stop) def _getitem_range(self, start: IndexType, stop: IndexType) -> Content: + print("\nListOffsetArray::_getitem_range", self, start, stop) # noqa: T201 + if not self._backend.nplike.known_data: self._touch_shape(recursive=False) return self @@ -350,6 +354,8 @@ def _getitem_fields( ) def _carry(self, carry: Index, allow_lazy: bool) -> Content: + print("\nListOffsetArray::_carry", self, carry, allow_lazy) # noqa: T201 + assert isinstance(carry, ak.index.Index) try: @@ -417,6 +423,14 @@ def _broadcast_tooffsets64(self, offsets: Index) -> ListOffsetArray: def _getitem_next_jagged( self, slicestarts: Index, slicestops: Index, slicecontent: Content, tail ) -> Content: + print( # noqa: T201 + "\nListOffsetArray::_getitem_next_jagged", + self, + slicestarts, + slicestops, + slicecontent, + ) + out = ak.contents.ListArray( self.starts, self.stops, self._content, parameters=self._parameters ) @@ -428,6 +442,8 @@ def _getitem_next( tail: tuple[SliceItem, ...], advanced: Index | None, ) -> Content: + print("\nListOffsetArray::_getitem_next", self, head, tail, advanced) # noqa: T201 + if head is NO_HEAD: return self diff --git a/src/awkward/contents/numpyarray.py b/src/awkward/contents/numpyarray.py index 11a73bb124..c0cb6b3c7e 100644 --- a/src/awkward/contents/numpyarray.py +++ b/src/awkward/contents/numpyarray.py @@ -310,6 +310,8 @@ def _is_getitem_at_placeholder(self) -> bool: return isinstance(self._data, PlaceholderArray) def _getitem_at(self, where: IndexType): + print("\nNumpyArray::_getitem_at", self, where) # noqa: T201 + if not self._backend.nplike.known_data and len(self._data.shape) == 1: self._touch_data(recursive=False) return TypeTracerArray._new(self._data.dtype, shape=()) @@ -325,6 +327,8 @@ def _getitem_at(self, where: IndexType): return out def _getitem_range(self, start: IndexType, stop: IndexType) -> Content: + print("\nNumpyArray::_getitem_range", self, start, stop) # noqa: T201 + try: out = self._data[start:stop] except IndexError as err: @@ -345,6 +349,8 @@ def _getitem_fields( raise ak._errors.index_error(self, where, "not an array of records") def _carry(self, carry: Index, allow_lazy: bool) -> Content: + print("\nNumpyArray::_carry", self, carry, allow_lazy) # noqa: T201 + assert isinstance(carry, ak.index.Index) try: nextdata = self._data[carry.data] @@ -355,6 +361,14 @@ def _carry(self, carry: Index, allow_lazy: bool) -> Content: def _getitem_next_jagged( self, slicestarts: Index, slicestops: Index, slicecontent: Content, tail ) -> Content: + print( # noqa: T201 + "\nNumpyArray::_getitem_next_jagged", + self, + slicestarts, + slicestops, + slicecontent, + ) + if self._data.ndim == 1: raise ak._errors.index_error( self, @@ -375,6 +389,8 @@ def _getitem_next( tail: tuple[SliceItem, ...], advanced: Index | None, ) -> Content: + print("\nNumpyArray::_getitem_next", self, head, tail, advanced) # noqa: T201 + if head is NO_HEAD: return self