Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-07 Thread Sebastian Haase
Sasha wrote: > On 7/6/06, Bill Baxter <[EMAIL PROTECTED]> wrote: >> ... >> Yep, like Tim said. The usage is say a N sets of basis vectors. Each set >> of basis vectors is a matrix. > > This brings up a feature that I really miss from numpy: an ability to do > > array([f(x) for x in a]) > > wit

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-07 Thread David M. Cooke
On Fri, 7 Jul 2006 15:26:41 +0100 "George Nurser" <[EMAIL PROTECTED]> wrote: > On 07/07/06, Robert Hetland <[EMAIL PROTECTED]> wrote: > [snip] > > However, I use transpose often when not dealing with linear algebra, in > > particular with reading in data, and putting various columns into > > varia

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-07 Thread Christopher Barker
Robert Kern wrote: > Just > because linear algebra is "the base" for a lot of numerical computing does > not > mean that everyone is using numpy arrays for linear algebra all the time. > Much > less does it mean that all of those conventions you've devised should be > shoved > into the core

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-07 Thread Gary Ruben
Sasha wrote: > On 7/6/06, Bill Baxter <[EMAIL PROTECTED]> wrote: >> ... >> Yep, like Tim said. The usage is say a N sets of basis vectors. Each set >> of basis vectors is a matrix. > > This brings up a feature that I really miss from numpy: an ability to do > > array([f(x) for x in a]) > > wit

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-07 Thread George Nurser
On 07/07/06, Robert Hetland <[EMAIL PROTECTED]> wrote: [snip] > However, I use transpose often when not dealing with linear algebra, in > particular with reading in data, and putting various columns into > variables. Also, occasional in plotting (which expects things in 'backward' > order relative

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-07 Thread Robert Hetland
On Jul 6, 2006, at 2:54 PM, Robert Kern wrote:I don't think that just because arrays are often used for linear algebra that  linear algebra assumptions should be built in to the core array type. True.  This argues against the MAH attributes.  However, I use transpose often when not dealing with lin

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-07 Thread Bill Baxter
I think the thread to this point can be pretty much summarized by:while True:    Bill: "2D transpose is common so it should have a nice syntax"    Tim, Robert, Sasha, and Ed: "No it's not." Very well.  I think it may be a self fulfilling prophecy, though.  I.e. if matrix operations are cumbersome t

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-07 Thread Tim Hochberg
Bill Baxter wrote: > On 7/7/06, *Robert Kern* <[EMAIL PROTECTED] > > wrote: > > Bill Baxter wrote: > > I am also curious, given the number of times I've heard this > nebulous > > argument of "there are lots kinds of numerical computing that don't > > i

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Bill Baxter
On 7/7/06, Robert Kern <[EMAIL PROTECTED]> wrote: Bill Baxter wrote:> I am also curious, given the number of times I've heard this nebulous> argument of "there are lots kinds of numerical computing that don't> invlolve linear algebra", that no one ever seems to name any of these > "lots of kinds". 

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Tim Hochberg
Sasha wrote: > On 7/6/06, Bill Baxter <[EMAIL PROTECTED]> wrote: > >> ... >> Yep, like Tim said. The usage is say a N sets of basis vectors. Each set >> of basis vectors is a matrix. >> > > This brings up a feature that I really miss from numpy: an ability to do > > array([f(x) for x in a

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Sasha
On 7/6/06, Bill Baxter <[EMAIL PROTECTED]> wrote: > ... > Yep, like Tim said. The usage is say a N sets of basis vectors. Each set > of basis vectors is a matrix. This brings up a feature that I really miss from numpy: an ability to do array([f(x) for x in a]) without python overhead. APL-lik

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Robert Kern
Bill Baxter wrote: > On 7/7/06, *Robert Kern* <[EMAIL PROTECTED] > > wrote: > > Bill Baxter wrote: > > Robert Kern wrote: [snip] > > I don't think that just because arrays are often used for linear > > algebra that > > > > linear

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Bill Baxter
On 7/7/06, Robert Kern <[EMAIL PROTECTED]> wrote: Bill Baxter wrote:> Robert Kern wrote:>>> The slippery slope argument only applies to the .M, not the .T or .H.No, it was the "Let's have a .T attribute. And if we're going to do that, then we should also do this. And this. And this."There's no slip

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Robert Kern
Bill Baxter wrote: > Robert Kern wrote: > > Like Sasha, I'm mildly opposed to .T (as a synonym for .transpose()) > and much > more opposed to the rest (including .T being a synonym for > .swapaxes(-2, -1)). > It's not often that a proposal carries with it its own > slippery

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Bill Baxter
Tim Wrote:That second argument is particularly uncompelling, but I think I agreethat in a vacuum swapaxes(-2,-1) would be a better choice for .T than reversing the axes. However, we're not in a vacuum and there are severalreasons not to do this.    1. A.T and A.transpose() should really have the sa

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Tim Hochberg
Sasha wrote: > On 7/6/06, Robert Kern <[EMAIL PROTECTED]> wrote: > >> ... >> I don't think that just because arrays are often used for linear algebra that >> linear algebra assumptions should be built in to the core array type. >> >> > > In addition, transpose is a (rank-2) array or matrix

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Sasha
On 7/6/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > ... > It looks even closer to † (dagger if that doesn't make it through) which > is the symbol used for the hermitian adjoint. If it pleases the matlab crowd, '+' can be defined to do the hermitian adjoint. on the complex type. > ... > Perhaps

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Sasha
On 7/6/06, Robert Kern <[EMAIL PROTECTED]> wrote: > ... > I don't think that just because arrays are often used for linear algebra that > linear algebra assumptions should be built in to the core array type. > In addition, transpose is a (rank-2) array or matrix operation and not a linear algebra

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Tim Hochberg
Alexander Belopolsky wrote: > On 7/6/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: >> ... >> Overloading '+' sure seems perverse, but maybe that's just me. >> > The first time I saw it, it seemed perverse to me as well, but it > actually make a lot of sense: > > 1. It is visually appealing as in '+'

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Sasha
On 7/6/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > ... > Overloading '+' sure seems perverse, but maybe that's just me. > The first time I saw it, it seemed perverse to me as well, but it actually make a lot of sense: 1. It is visually appealing as in '+' makes '|' from '-' and '-' from '|' and

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Alexander Belopolsky
On 7/6/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > ... > Overloading '+' sure seems perverse, but maybe that's just me. > The first time I saw it, it seemed perverse to me as well, but it actually make a lot of sense: 1. It is visually appealing as in '+' makes '|' from '-' and '-' from '|' and

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Alexander Belopolsky
On 7/6/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > ... > So this is essentially turning a row vector into a column vector? Is > that right? > Being a definition, this is neither right nor wrong. It all depends on what you are using it for. If you want to distinguish row and column vectors, you h

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Robert Kern
Travis Oliphant wrote: > Bill Baxter wrote: >> So in short my proposal is to: >> -- make a.T a property of array that returns a.swapaxes(-2,-1), >> -- make a.H a property of array that returns >> a.conjugate().swapaxes(-2,-1) >> and maybe >> -- make a.M a property of array that returns numpy.as

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Tim Hochberg
Sasha wrote: > On 7/6/06, Bill Baxter <[EMAIL PROTECTED]> wrote: > >> On 7/7/06, Sasha <[EMAIL PROTECTED]> wrote: >> ... I think it's much >> more common to want to swap just two axes, and the last two seem a logical >> choice since a) in the default C-ordering they're the closest together in >>

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Sasha
On 7/6/06, Bill Baxter <[EMAIL PROTECTED]> wrote: > > > On 7/7/06, Sasha <[EMAIL PROTECTED]> wrote: > ... I think it's much > more common to want to swap just two axes, and the last two seem a logical > choice since a) in the default C-ordering they're the closest together in > memory and b) they'r

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Tim Hochberg
Sven Schreiber wrote: > Tim Hochberg schrieb: > > -) .I for inverse; actually, why not add that to arrays as well as "syntactic sugar"? >>> Because it encourages people to do the wrong thing numerically speaking? >>> My understanding is that one almost

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Bill Baxter
On 7/7/06, Sasha <[EMAIL PROTECTED]> wrote: I would like to raise a few objections going from mild to strong:1. .T : I am mildly against it.  As an inexpensive operation thatreturns a view (so that a.T[...] = makes sense) it is a reasonablecandidate for an attribute.   Unfortunately reversing the o

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Keith Goodman
On 7/6/06, Sven Schreiber <[EMAIL PROTECTED]> wrote: > Maybe you guys as the developers of numpy should really make up your > mind about the future of matrices in numpy. Either it's supported, then > eventually I would expect matrix versions of ones, zeros, eye, for > example. (Although eye().M wo

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Sven Schreiber
Tim Hochberg schrieb: >>> -) .I for inverse; actually, why not add that to arrays as well as >>> "syntactic sugar"? >>> >>> >> Because it encourages people to do the wrong thing numerically speaking? >> My understanding is that one almost never wants to compute the inverse >> directly, a

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Sasha
I would like to raise a few objections going from mild to strong: 1. .T : I am mildly against it. As an inexpensive operation that returns a view (so that a.T[...] = makes sense) it is a reasonable candidate for an attribute. Unfortunately reversing the order of axes at least as reasonable as sw

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Tim Hochberg
Bill Baxter wrote: > On 7/6/06, *Tim Hochberg* <[EMAIL PROTECTED] > > wrote: > > > -) Being able to distinguish between row and column vectors; I guess > > this is just not possible with arrays... > > > Why can't you distinguish between them the same way t

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Tim Hochberg
Tim Hochberg wrote: > Sven Schreiber wrote: > >> Travis Oliphant schrieb: >> >> >>> Bill Baxter wrote: >>> >>> So in short my proposal is to: -- make a.T a property of array that returns a.swapaxes(-2,-1), -- make a.H a property of array that returns a.

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Bill Baxter
On 7/6/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > -) Being able to distinguish between row and column vectors; I guess> this is just not possible with arrays...>Why can't you distinguish between them the same way that the matrixclass does? Shape [1, N] is a row array, shape [N,1] is column array

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Tim Hochberg
Sven Schreiber wrote: > Travis Oliphant schrieb: > >> Bill Baxter wrote: >> >>> So in short my proposal is to: >>> -- make a.T a property of array that returns a.swapaxes(-2,-1), >>> -- make a.H a property of array that returns >>> a.conjugate().swapaxes(-2,-1) >>> and maybe >>> -- make

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Bill Baxter
On 7/6/06, Sven Schreiber <[EMAIL PROTECTED]> wrote: Travis Oliphant schrieb:> Bill Baxter wrote:>> So in short my proposal is to:>> --  make a.T a property of array that returns a.swapaxes(-2,-1),>> --  make a.H a property of array that returns >> a.conjugate().swapaxes(-2,-1)>> and maybe>> --  ma

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Sven Schreiber
Travis Oliphant schrieb: > Bill Baxter wrote: >> So in short my proposal is to: >> -- make a.T a property of array that returns a.swapaxes(-2,-1), >> -- make a.H a property of array that returns >> a.conjugate().swapaxes(-2,-1) >> and maybe >> -- make a.M a property of array that returns numpy.

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Travis Oliphant
Bill Baxter wrote: > So in short my proposal is to: > -- make a.T a property of array that returns a.swapaxes(-2,-1), > -- make a.H a property of array that returns > a.conjugate().swapaxes(-2,-1) > and maybe > -- make a.M a property of array that returns numpy.asmatrix(a) I've tentatively imp

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-04 Thread Bill Baxter
Slight correction.{*} except that negative axes for swapaxes doesn't seem work currently, so instead it would need to be something like:       a.transpose( a.shape[:-2] + (a.shape[-1],a.shape[-2]) )   with a check for "if ndim > 1", of course.Apparently a.swapaxes(-2,-1) does work, and it does exac