Skip to content
Merged
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
14 changes: 10 additions & 4 deletions pytools/obj_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,21 @@ def __matmul__(
self: ObjectArray2D[T],
other: ObjectArray2D[T],
/) -> ObjectArray2D[T]: ...

@overload
def __matmul__(
self: ObjectArray2D[T],
other: np.ndarray[tuple[int, int], np.dtype[Any]],
/) -> ObjectArray2D[T]: ...
Comment thread
inducer marked this conversation as resolved.
@overload
def __matmul__(
self: ObjectArrayND[T],
other: ObjectArrayND[T],
/) -> ObjectArrayND[T] | T: ...

@property
def flat(self) -> ObjectArray1D[T]: ...
def flat(self) -> Iterator[T]: ...
Comment thread
inducer marked this conversation as resolved.

def flatten(self) -> ObjectArray1D[T]: ...

@overload
def tolist(self: ObjectArray0D[T]) -> T: ...
Expand Down Expand Up @@ -439,7 +445,7 @@ def sum(

def sum(
array: ObjectArrayND[T],
axis: int | None,
axis: int | None = None,
Comment thread
inducer marked this conversation as resolved.
) -> ObjectArrayND[T] | T:
import numpy as np
return cast("ObjectArrayND[T] | T", np.sum(
Expand All @@ -451,7 +457,7 @@ def sum(
def to_hashable(ary: ObjectArray[ShapeT, T] | Hashable, /) -> Hashable:
if isinstance(ary, ObjectArray):
ary = cast("ObjectArray[ShapeT, T]", ary)
return tuple(ary.flat.tolist())
return tuple(ary.flat)
return ary


Expand Down
Loading