Skip to content
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

DO NOT MERGE: print-outs to diagnose issue #3213 #3216

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/awkward/contents/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
20 changes: 20 additions & 0 deletions src/awkward/contents/listarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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)

Expand Down
16 changes: 16 additions & 0 deletions src/awkward/contents/listoffsetarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
)
Expand All @@ -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

Expand Down
16 changes: 16 additions & 0 deletions src/awkward/contents/numpyarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=())
Expand All @@ -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:
Expand All @@ -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]
Expand All @@ -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,
Expand All @@ -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

Expand Down
Loading