[Numpy-discussion] Syntax Improvement for Array Transpose

Todd toddrjen at gmail.com
Mon Jun 24 10:24:09 EDT 2019


I think we need to do something about the 1D case.  I know from a strict
mathematical standpoint it doesn't do anything, and philosophically we
should avoid special cases, but I think the current solution leads to
enough confusion and silently doing an unexpected thing that I think we
need a better approach.

Personally I think it is a nonsensical operation and so should result in an
exception, but at the very least I think it needs to raise a warning.

On Mon, Jun 24, 2019, 09:54 Hameer Abbasi <einstein.edison at gmail.com> wrote:

> Hello Marten,
>
> I was suggesting not changing the shape at all, since dot/matmul/solve do
> the right thing already in such a case.
>
> In my proposal, only for ndim >=2 do we switch the last two dimensions.
>
> Ilhan is right that adding a special case for ndim=1 (error) adds
> programmer overhead, which is against the general philosophy of NumPy I
> feel.
>
> Get Outlook for iOS <https://aka.ms/o0ukef>
>
> ------------------------------
> *From:* NumPy-Discussion <numpy-discussion-bounces+einstein.edison=
> gmail.com at python.org> on behalf of Marten van Kerkwijk <
> m.h.vankerkwijk at gmail.com>
> *Sent:* Monday, June 24, 2019 3:24 PM
> *To:* Discussion of Numerical Python
> *Subject:* Re: [Numpy-discussion] Syntax Improvement for Array Transpose
>
> Dear Hameer, Ilhan,
>
> Just to be sure: for a 1-d array, you'd both consider `.T` giving a shape
> of `(n, 1)` the right behaviour? I.e., it should still change from what it
> is now - which is to leave the shape at `(n,)`.
>
> Your argument about `dot` and `matmul` having similar behaviour certainly
> adds weight (but then, as I wrote before, my opinion on this changes by the
> second, so I'm very happy to defer to others who have a clearer sense of
> what is the right thing to do here!).
>
> I think my main worry now is how to get to be able to use a new state
> without having to wait 4..6 releases...
>
> All the best,
>
> Marten
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20190624/7e8628c8/attachment.html>


More information about the NumPy-Discussion mailing list