Hi all!

The Array API standard states that `T` property should only be applied to 
2-dimensional arrays, in all other cases it should raise an error:
https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.T

To ensure that NumPy also follows this rule, I opened a PR that raises a 
warning for `arr.T` for non-2-dimensional arrays and scalars: 
https://github.com/numpy/numpy/pull/28678

For non-2-dimensional arrays, the replacement for `arr.T` can be either: Array 
API compatible, namely `np.permute_dims(arr, range(arr.ndim)[::-1])`, or 
shorter, NumPy specific: `arr.transpose()`.

The new discrepancy between `arr.T` and `arr.transpose()` is justified, as `T` 
is defined by the Array API, where `transpose` isn't and should retain the 
existing behavior.

Please share your thoughts! 

Best regards,
Mateusz
_______________________________________________
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com

Reply via email to