[Numpy-discussion] ndarray.T2 for 2D transpose

Joseph Martinot-Lagarde contrebasse at gmail.com
Thu Apr 7 05:31:34 EDT 2016


> > For a 1D array a of shape (N,), I expect a.T2 to be of shape (N, 1),
> 
> Why not (1,N)? -- it is not well defined, though I suppose it's not so
> bad to establish a convention that a 1-D array is a "row vector"
> rather than a "column vector".
I like Todd's simple proposal: a.T2 should be equivalent to np.atleast_2d(arr).T

> BTW, if transposing a (N,) array gives you a (N,1) array, what does
> transposing a (N,1) array give you?
> 
> (1,N) or (N,) ?
The proposal changes nothin for dims > 1, so (1,N). That means that a.T2.T2
doesn"t have the same shape as a.

It boils down to practicality vs purity, as often !





More information about the NumPy-Discussion mailing list