Skip to content

Commit

Permalink
avoid touching shape too much for purelist_depth, minmax_depth, and b…
Browse files Browse the repository at this point in the history
…ranch_depth using inner_shape property
  • Loading branch information
pfackeldey committed Sep 23, 2024
1 parent 8720a05 commit 1af4376
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/awkward/contents/numpyarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ def shape(self) -> tuple[ShapeItem, ...]:

@property
def inner_shape(self) -> tuple[ShapeItem, ...]:
return self._data.shape[1:]
if hasattr(self._data, "inner_shape"):
inner_shape = self._data.inner_shape
else:
inner_shape = self._data.shape[1:]
return inner_shape

@property
def strides(self) -> tuple[ShapeItem, ...]:
Expand All @@ -189,14 +193,9 @@ def _raw(self, nplike=None):
return to_nplike(self.data, nplike, from_nplike=self._backend.nplike)

def _form_with_key(self, getkey: Callable[[Content], str | None]) -> NumpyForm:
if hasattr(self._data, "inner_shape"):
inner_shape = self._data.inner_shape
else:
inner_shape = self._data.shape[1:]

return self.form_cls(
ak.types.numpytype.dtype_to_primitive(self._data.dtype),
inner_shape,
self.inner_shape,
parameters=self._parameters,
form_key=getkey(self),
)
Expand Down

0 comments on commit 1af4376

Please sign in to comment.