Open ajpotts opened 1 week ago
I investigated this a bit. It seems like the best solution might be to have an array_like
type variable, something like this:
array_like = Union[numeric_scalars, pdarray, Sequence[pdarray]]
and restrict the Array._array
object to the array_like
type.
However, this would require a refactor of a number of functions that call the attributes of _array
. For example:
def empty_like(x: Array, /, *, dtype: Optional[Dtype] = None, device: Optional[Device] = None) -> Array:
"""
Return a new array whose shape and dtype match the input array, without initializing entries.
"""
from .array_object import Array
if device not in ["cpu", None]:
raise ValueError(f"Unsupported device {device!r}")
t = x.dtype if dtype is None else akdtype(dtype)
return Array._new(
pdarray(
"__empty__",
t,
x._array.size,
x._array.ndim,
x._array.shape,
x._array.itemsize,
x._array.max_bits,
),
empty=True,
)
Describe the bug
Array
creation inarray_api
gives unexpected result forArray._new(x)
whenx
is anArray
.To Reproduce