array-api
array-api copied to clipboard
feat: add `diff` to specification
This PR
- resolves https://github.com/data-apis/array-api/issues/784 by adding
diffto the specification. - restricts portable behavior for
prependandappendto arrays. While NumPy and others support scalars (a common use case), PyTorch does not support scalars. - supports all numeric dtypes (real and complex floats, signed and unsigned integers).
- allows some wiggle room for array libraries supporting "exotic" dtypes, such as datetimes, by stating that the output array "should" have the same data type as the input array
x. E.g., NumPy supports datetimes and returns timedeltas. For numeric dtypes, the output array should always have the same dtype. - restricts
prependandappendto the same data type as the input array. If we more generally allow any combination of dtypes amongx,prepend, andappend, we'd need to consider type promotion semantics. We don't have much, if any, precedent in the specification for array kwargs causing an input array to upcast, and I don't think we should establish precedent here. - set the defaults for
prependandappendtoNone. This is in contrast to NumPy which doesn't set a default value.