[Numpy-discussion] ndarray.T2 for 2D transpose
toddrjen at gmail.com
Wed Apr 6 13:39:49 EDT 2016
I would make `arr.T2` the same as `np.atleast_2d(arr).T`. So a 1D array
would act as a row vector, since that is already the convention for
coercing 1D arrays to 2D.
On Tue, Apr 5, 2016 at 10:49 PM, Juan Nunez-Iglesias <jni.soma at gmail.com>
> Would you consider a 1D array to be a row vector or a column vector for
> the purposes of transposition? The "correct" answer is not clear to me.
> On Wed, Apr 6, 2016 at 12:26 PM, Alan Isaac <alan.isaac at gmail.com> wrote:
>> On 4/5/2016 10:11 PM, Todd wrote:
>>> When you try to transpose a 1D array, it does nothing. This is the
>>> correct behavior, since it transposing a 1D array is meaningless.
>>> However, this can often lead to unexpected errors since this is rarely
>>> what you want. You can convert the array to 2D, using `np.atleast_2d`
>>> or `arr[None]`, but this makes simple linear algebra computations more
>>> I propose adding an argument to transpose, perhaps called `expand` or
>>> `expanddim`, which if `True` (it is `False` by default) will force the
>>> array to be at least 2D. A shortcut property, `ndarray.T2`, would be
>>> the same as `ndarray.transpose(True)`.
>> Use `dot`. E.g.,
>> Alan Isaac
>> NumPy-Discussion mailing list
>> NumPy-Discussion at scipy.org
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion