[Numpy-discussion] next NumPy triage meeting - Wednesday, April 16th, 2025 at 5 pm UTC
The next NumPy triage meeting will be held this Wednesday, April 16th at 17:00 (5 pm) UTC. This is a meeting where we synchronously triage prioritized PRs and issues. Everyone is welcome to attend and contribute to a conversation. Join us via Zoom: https://numfocus-org.zoom.us/j/82096749952?pwd=MW9oUmtKQ1c3a2gydGk1RTdYUUVXZz09 Please notify us of issues or PRs that you’d like to have reviewed by adding a GitHub link to them in the meeting agenda: https://hackmd.io/68i_JvOYQfy9ERiHgXMPvg -- Cheers, Inessa Inessa Pawson GitHub: inessapawson ___ 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
[Numpy-discussion] Re: Making `T` property Array API compatible
> 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. The other side of the coin here is that this change would fix the discrepancy between `arr.T` and the functions `np.matrix_transpose` and `np.linalg.matrix_transpose`, which implement batched transpose over matrices in the 2 innermost dimensions, rather than reversing all axes. In [*10*]: X = np.stack((np.eye(2), np.eye(2))) In [*12*]: X.T Out[*12*]: array([[[1., 1.], [0., 0.]], [[0., 0.], [1., 1.]]]) In [*13*]: np.matrix_transpose(X) Out[*13*]: array([[[1., 0.], [0., 1.]], [[1., 0.], [0., 1.]]]) Cheers, Lucas On 12 Apr 2025, at 11:14, Mateusz Sokol wrote: 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: lucas.coll...@gmail.com ___ 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
[Numpy-discussion] Re: Making `T` property Array API compatible
On Sat, Apr 12, 2025 at 12:13 PM Mateusz Sokol wrote: > 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! > After seeing this message, I wasn't 100% sure that we didn't leave this change out of 2.0 on purpose. I did some searching and I don't think that's the case - we just forgot it. It is mentioned in NEP 56 as a backwards incompatible change with low impact: https://numpy.org/neps/nep-0056-array-api-main-namespace.html#backward-compatibility. So it looks fine to me to move ahead. Cheers, Ralf ___ 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
[Numpy-discussion] Making `T` property Array API compatible
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