[Numpy-discussion] Syntax Improvement for Array Transpose

Juan Nunez-Iglesias jni.soma at gmail.com
Tue Jun 25 09:34:51 EDT 2019


On Mon, 24 Jun 2019, at 11:25 PM, Marten van Kerkwijk wrote:
> Just to be sure: for a 1-d array, you'd both consider `.T` giving a shape of `(n, 1)` the right behaviour? I.e., it should still change from what it is now - which is to leave the shape at `(n,)`.

Just to chime in as a user: v.T should continue to be a silent no-op for 1D arrays. NumPy makes it arbitrary whether a 1D array is viewed as a row or column vector, but we often want to write .T to match the notation in a paper we're implementing.

More deeply, I think .T should never change the number of dimensions of an array.

I'm ambivalent about the whole discussion in this thread, but generally I think NumPy should err on the side of caution when deprecating behaviour. It's unclear to me whether the benefits of making .T transpose only the last two dimensions outweigh the costs of deprecation. Despite some people's assertion that those using .T to transpose >2D arrays are probably making a mistake, we have two perfectly correct uses in scikit-image. These could be easily changed to .transpose() (honestly they probably should!), but they illustrate that there is some amount of correct code out there that would be forced to keep up with an update here.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20190625/47cc3596/attachment-0001.html>


More information about the NumPy-Discussion mailing list