[Numpy-discussion] ndarray.T2 for 2D transpose
Chris Barker
chris.barker at noaa.gov
Wed Apr 6 16:50:34 EDT 2016
On Wed, Apr 6, 2016 at 10:47 AM, Todd <toddrjen at gmail.com> wrote:
>
> 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.
>
not really -- you still need to use arrays that are the "correct" shape.
Ideally, a row vector is (1, N) and a column vector is (N,1). Though I know
there are places that a 1-D array is treated as a column vector.
>
>
>> 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.
>
my point is that for 2D arrays: arr.T.T == arr, but in this case, we would
be making a one way street:
when you transpose a 1D array, you treat it as a row vector, and return a
"column vector" -- a (N,1) array.
But when you transpose a "column vector" to get a row vector, you get a
(1,N) array, not a (N) array.
So I think we need to either have proper row and column vectors (to go with
matrices) or require people to create the appropriate 2D arrays.
Perhaps there should be an easier more obvious way to spell "make this a
column vector", but I don't think .T is it.
Though arr.shape = (-1,1) has always worked fine for me.
-CHB
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20160406/973fecfb/attachment.html>
More information about the NumPy-Discussion
mailing list