-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
DEP: Deprecate .T
property for non-2dim arrays and scalars
#28678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
* ``arr.T`` property has been deprecated for array scalars and arrays with | ||
dimensionality different than ``2``. | ||
* ``arr.T`` property has been deprecated for array scalars and arrays with dimensionality | ||
different than ``2`` to be compatible with the Array API standard. To achieve the same | ||
behavior when ``arr.ndim != 2``, either ``np.permute_dims(arr, range(arr.ndim)[::-1])`` | ||
(also compatible with the Array API) or ``arr.transpose()`` can be used. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -852,7 +852,10 @@ array_transpose_get(PyArrayObject *self, void *NPY_UNUSED(ignored)) | |
if (ndim != 2) { | ||
seberg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (PyErr_WarnFormat(PyExc_UserWarning, 1, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why a We could use a visible deprecation warning if we want to inform new users who accidentally get it wrong. But only if we take the trouble to check that very few libraries use this (i.e. there are few places in existing code where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So, it must clearly be a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done - for array scalars in |
||
"In the future `.T` property will be supported for " | ||
"2-dim arrays only. Here it is %d-dim array.", | ||
"2-dim arrays only. Received %d-dim array. Either " | ||
"`np.permute_dims(arr, range(arr.ndim)[::-1])` " | ||
"(compatible with the Array API) or `arr.transpose()` " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would delete the note and at least re-order this. It nudges users to something less convenient for what seems very little reason to me. It may be good to note that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And what if someone uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's what Sebastian is saying - to leave There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel it currently makes it seem that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for an explanation! I updated the message as you suggested. |
||
"should be used instead.", | ||
rgommers marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ndim) < 0) { | ||
return NULL; | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.