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

Todd toddrjen at gmail.com
Wed Apr 6 13:47:14 EDT 2016

On Wed, Apr 6, 2016 at 11:44 AM, Chris Barker - NOAA Federal <
chris.barker at noaa.gov> wrote:

> But the truth is that Numpy arrays are arrays, not matrices and vectors.
> The "right" way to do this is to properly extend and support the
> matrix object, adding row and column vector objects, and then it would
> be clear. But while there has been a lot of discussion about that in
> the past, the fact is that no one wants it bad enough to write the
> code.
> So I think it's better to keep Numpy arrays "pure", and if you want to
> change the rank of an array, you do so explicitly.

I think that cat is already out of the bag.  As long as you can do matrix
multiplication on arrays using the @ operator, I think they aren't really
"pure" anymore.

> 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,) ?

My suggestion is that this explicitly increases the number of dimensions to
at least 2.  The result will always have at least 2 dimensions.  So 0D ->
2D, 1D -> 2D, 2D -> 2D, 3D -> 3D, 4D -> 4D, etc.  So this would be
equivalent to the existing `atleast_2d` function.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20160406/d33af754/attachment.html>

More information about the NumPy-Discussion mailing list