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
28 changes: 0 additions & 28 deletions array.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class ArrayIsh(Protocol):
shape: tuple[int, ...]
strides: tuple[int, ...]
dtype: np.dtype[Any]
bytes: int


class ArrayFlags:
Expand Down Expand Up @@ -141,33 +140,6 @@ def get_common_dtype(obj1: ArrayIsh, obj2: ArrayIsh,
return result


def bound(a: ArrayIsh) -> tuple[int, int]:
high = a.bytes
low = a.bytes

for stri, shp in zip(a.strides, a.shape, strict=True):
if stri < 0:
low += (stri)*(shp-1)
else:
high += (stri)*(shp-1)
return low, high


def may_share_memory(a: ArrayIsh, b: ArrayIsh) -> bool:
# When this is called with a an ndarray and b
# a sparse matrix, numpy.may_share_memory fails.
if a is b:
return True
if a.__class__ is b.__class__:
a_l, a_h = bound(a)
b_l, b_h = bound(b)
if b_l >= a_h or a_l >= b_h:
return False
return True
else:
return False


# {{{ as_strided implementation

try:
Expand Down