On Sun, 2019-06-23 at 19:51 +0000, Hameer Abbasi wrote: > +1 for this. I have often seen (and sometimes written) code that does > this automatically, and it is a common mistake.
Yeah, likely worth a short. I doubt many uses for the n-dimensional axis transpose, so maybe a futurewarning approach can work. If not, I suppose the solution is the deprecation for ndim != 2. Another point about the `.T` is the 1-dimensional case, which commonly causes confusion. If we do something here, should think about that as well. - Sebastian > > However, we will need some way to filter for intent, as the people > who write this code are the ones who didn’t read docs on it at the > time, and so there might be a fair amount of noise even if it fixes > their code. > > I also agree that a transpose of an array with ndim > 2 doesn’t make > sense without specifying the order, at least for the applications I > have seen so far. > > Get Outlook for iOS > > From: NumPy-Discussion < > numpy-discussion-bounces+einstein.edison=gmail....@python.org> on > behalf of Eric Wieser <wieser.eric+nu...@gmail.com> > Sent: Sunday, June 23, 2019 9:24 PM > To: Discussion of Numerical Python > Subject: Re: [Numpy-discussion] Syntax Improvement for Array > Transpose > > This might be contentious, but I wonder if, with a long enough > deprecation cycle, we can change the meaning of .T. That would look > like: > > * Emit a future warning on `more_than_2d.T` with a message like "in > future .T will transpose just the last two dimensions, not all > dimensions. Use are.transpose() if transposing all {n} dimensions is > deliberate" > * Wait 5 releases or so, see how many matches Google / GitHub has for > this warning. > * If the impact is minimal, change .T > * If the impact is large, change to a deprecation warning > > An argument for this approach: a good amount of code I've seen in the > wild already assumes T is a 2d transpose, and as a result does not > work correctly when called with stacks of arrays. Changing T might > fix this broken code automatically. > > If the change would be too intrusive, then keeping the deprecation > warning at least prevents new users deliberately using .T for >2d > transposes, which is possibly valuable for readers. > > Eric > > > On Sun, Jun 23, 2019, 12:05 Stewart Clelland < > stewartclell...@gmail.com> wrote: > > Hi All, > > > > Based on discussion with Marten on github, I have a couple of > > suggestions on syntax improvements on array transpose operations. > > > > First, introducing a shorthand for the Hermitian Transpose > > operator. I thought "A.HT" might be a viable candidate. > > > > Second, the adding an array method that operates like a normal > > transpose. To my understanding, > > "A.tranpose()" currently inverts the usual order of all dimensions. > > This may be useful in some applications involving tensors, but is > > not what I would usually assume a transpose on a multi-dimensional > > array would entail. I suggest a syntax of "A.MT" to indicate a > > transpose of the last two dimensions by default, maybe with > > optional arguments (i,j) to indicate which two dimensions to > > transpose. > > > > I'm new to this mailing list format, hopefully I'm doing this right > > :) > > > > Thanks, > > Stew > > _______________________________________________ > > NumPy-Discussion mailing list > > NumPy-Discussion@python.org > > https://mail.python.org/mailman/listinfo/numpy-discussion > > > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@python.org > https://mail.python.org/mailman/listinfo/numpy-discussion
signature.asc
Description: This is a digitally signed message part
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion