Description
Proposed new feature or change:
I was testing how to add support for the array API standard to a small project of mine. However, I also wanted to remain compatible with Numpy ndarray
, as it is what everyone uses right now. However, the differences in the API between the standard and ndarray
, and the decision to conform to the minimal implementation of the standard, make really difficult to support both use cases with the same code.
For example, in order to create a copy of the input array, which should be a simple thing to do, using the array standard I would need to call x = xp.asarray(x, copy=True)
. However, when I receive a numpy ndarray I fall back to xp = np
, and np.asarray
does not have the copy
parameter.
I can't just convert the ndarray
to Array
, both because I would be returning a different type than the input type, and because Array
does not allow the object
dtype, and I explicitly allow ndarray
s containing Fraction
or Decimal
objects.
The ideal choice would be either to make the basic Numpy ndarray
functions compatible with the standard, or to expose an advanced version of the array_api
that deals directly with ndarray
objects and support all Numpy functionalities in a manner compatible with the standard. Otherwise, making existing code compatible with both ndarray
and the API standard will require a lot of effort and duplicated code to accommodate both.