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

Ian Henriksen insertinterestingnamehere at gmail.com
Thu Apr 7 16:07:40 EDT 2016


On Thu, Apr 7, 2016 at 1:53 PM <josef.pktd at gmail.com> wrote:

> On Thu, Apr 7, 2016 at 3:26 PM, Ian Henriksen <
> insertinterestingnamehere at gmail.com> wrote:
>
>> On Thu, Apr 7, 2016 at 12:31 PM <josef.pktd at gmail.com> wrote:
>>
>>> write unit tests with non square 2d arrays and the exception / test
>>> error shows up fast.
>>>
>>> Josef
>>>
>>>
>> Absolutely, but good programming practices don't totally obviate helpful
>> error
>> messages.
>>
>
> The current behavior is perfectly well defined, and I don't want a lot of
> warnings showing up because .T works suddenly only for ndim != 1.
> I make lots of mistakes during programming. But shape mismatch are usually
> very fast to catch.
>
> If you want safe programming, then force everyone to use only 2-D like in
> matlab. It would have prevented me from making many mistakes.
>
> >>> np.array(1).T
> array(1)
>
> another noop. Why doesn't it convert it to 2d?
>
> Josef
>
>
I think we've misunderstood each other. Sorry if I was unclear. As I've
understood the discussion thus far, "raising an error" refers to raising an
error when
a 1D array is passed used with the syntax a.T2 (for swapping the last two
dimensions?). As far as whether or not a.T should raise an error for 1D
arrays, that
ship has definitely already sailed. I'm making the case that there's value
in having
an abbreviated syntax that helps prevent errors from accidentally using a
1D array,
not that we should change the existing semantics.

Cheers,

-Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20160407/c96b234f/attachment.html>


More information about the NumPy-Discussion mailing list