Description
-
We only aim to support numeric dtypes, which are undestood by pytorch. This rules out
- object arrays
- datetimes
- strings, chars and void dtypes
- structured dtypes and recarrays
np.longdouble
andnp.clongdouble
(a.k.a.np.float128
andnp.complex256
, respectively)
-
ndrray subclasses are out of scope.
-
masked arrays are out of scope
-
numpy polynomials are out of scope, both
np.poly1d
,np.polynomial
-
__array_function__
protocol is out of scope. This way, non-defaultlike=...
arguments raise. -
__array_interface__
is out of scope -
ndarray.ctypes
attribute not supported -
Negative strides:
tnp.flip
and slicing with negative step return a copy.
These differences exist currently, but might be fixable if desired:
-
We do not distinguish between 0D arrays and scalars. That is,
tnp.float32(3)
creates a zero-dim array.- One corollary is that scalars never silently decay into Python scalars, as NumPy scalars do in some situations:
In [1]: np.int32(2) * [1, 2, 3] # scalar decays to a python int
Out[1]: [1, 2, 3, 1, 2, 3]
In [2]: np.asarray(2) * [1, 2, 3] # zero-dim array is an array-like
Out[2]: array([2, 4, 6])
In our implementation, np.int32(2)
behaves identically to np.asarray(2)
.
-
We do not implement value-based casting. This will be deprecated in NumPy 2.0 as per NEP 50.
-
__array_wrap__
protocol is currently not implemented. -
gufunc machinery is not implemented, e.g.
axes=[(n,k),(k,m)->(n,m)]
arguments of ufunc objects. -
ufunc methods (
np.add.reduce
etc) are not implemented. -
Fortran ordered arrays in general, and
order="CFKA"
in various creation functions are not implemented. -
numpy.linalg
, handles zero-size arrays (sort of) uniformly, and pytorch doesn't handle these at all. We do not currently implement it. -
various estimators for the
np.histogram
bin selection are not implemented. -
nout=2
ufuncsout1=..., out2=...
positional arguments do not work (out=tuple kwargs work) -
sorting/ordering of complex data: numpy defines some ordering of complex values, pytorch errors out; we follow pytorch; relevant functions are
min/max
,argmin/argmax
,sort
andsearchsorted
. cf min/max for complex inputs #67 for discussion. -
tril_indices_from
/triu_indices_from
return tensors rather than list of tuples to avoid a graph break