Re: [Numpy-discussion] Array subclassing - question for Travis

2008-08-27 Thread Matthew Brett
Hi Stefan, Thanks for the kindly reply... > Since both those objects have an __array_priority__ of 0.0, I guess it > just takes whichever class comes first. > In [15]: class A(np.ndarray): > : __array_priority__ = -1.0 I think, playing more... For np.multiply, it does not seem possib

Re: [Numpy-discussion] subsampling array without loops

2008-08-27 Thread Stéfan van der Walt
2008/8/26 Anne Archibald <[EMAIL PROTECTED]>: > 2008/8/22 Catherine Moroney <[EMAIL PROTECTED]>: >> I'm looking for a way to acccomplish the following task without lots >> of loops involved, which are really slowing down my code. >> >> I have a 128x512 array which I want to break down into 2x2 squa

Re: [Numpy-discussion] [SciPy08] Documentation BoF

2008-08-27 Thread Stéfan van der Walt
Hi Neil 2008/8/26 Neil Crighton <[EMAIL PROTECTED]>: >> >> - Should we have a separate User manual and a Reference manual, or only >> a single manual? >> > > Are there still plans to write a 10 page 'Getting started with NumPy' > document? I think this would be very useful. Ideally a 'getting st

Re: [Numpy-discussion] Array subclassing - question for Travis

2008-08-27 Thread Stéfan van der Walt
Hey Matthew 2008/8/27 Matthew Brett <[EMAIL PROTECTED]>: > In [148]: type(np.multiply(arr, obj)) # this is what I expected > Out[148]: > > In [149]: type(np.multiply.outer(arr, obj)) # this is not - I expected > class A again > Out[149]: Since both those objects have an __array_priority__ of 0.

Re: [Numpy-discussion] normalizing a vector so it has magnitude 1

2008-08-27 Thread SimonPalmer
sorry, 1D array this is perfect, thanks. On Aug 27, 10:18 pm, Gary Ruben <[EMAIL PROTECTED]> wrote: > I don't know what you mean by a 1D vector, but for a 3-vector, you can > do this (also works for N-dimensions) > > In [1]: a=r_[1.,2.,3.] > In [2]: a > Out[2]: array([ 1., 2., 3.]) > In [3]: b=

Re: [Numpy-discussion] normalizing a vector so it has magnitude 1

2008-08-27 Thread Gary Ruben
I don't know what you mean by a 1D vector, but for a 3-vector, you can do this (also works for N-dimensions) In [1]: a=r_[1.,2.,3.] In [2]: a Out[2]: array([ 1., 2., 3.]) In [3]: b=a/norm(a) In [4]: b Out[4]: array([ 0.26726124, 0.53452248, 0.80178373]) Gary R > bit of a newb question, is t

[Numpy-discussion] normalizing a vector so it has magnitude 1

2008-08-27 Thread SimonPalmer
bit of a newb question, is there a method for normalising a 1D vector so it ends up with magnitude 1? I can do it manually but I was hoping there was a neat numpy - or scipy - trick. I've been web surfing but nothing really leaps out ___ Numpy-discussi

Re: [Numpy-discussion] About asarray (list)

2008-08-27 Thread Lisandro Dalcin
On Wed, Aug 27, 2008 at 12:01 PM, Claude Gouedard <[EMAIL PROTECTED]> wrote: > Ok , > The same for asarray(1) .. > The problem is that > aa=asarray(1) is an numpy.array (right ? ) with a size 1 and a shape ( ) ! > No surprising ? For me, this is not surprising at all :-) . Furthermore, if you try

Re: [Numpy-discussion] About asarray (list)

2008-08-27 Thread Dag Sverre Seljebotn
Claude Gouedard wrote: > Ok , > The same for asarray(1) .. > The problem is that > aa=asarray(1) is an numpy.array (right ? ) with a size 1 and a shape ( ) ! > No surprising ? I think it is considered a 0-dimensional array (= a scalar). -- Dag Sverre _

[Numpy-discussion] About asarray (list)

2008-08-27 Thread Claude Gouedard
Ok , The same for asarray(1) .. The problem is that aa=asarray(1) is an numpy.array (right ? ) with a size 1 and a shape ( ) ! No surprising ? Claude ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/

Re: [Numpy-discussion] About asarray (list)

2008-08-27 Thread Pauli Virtanen
Wed, 27 Aug 2008 16:48:48 +0200, Claude Gouedard wrote: > Hi , > > I'm just surprised by the behaviour of numpy.asarray on lists. > > Can someone comment this : > = > a=(1) > aa=asarray(a) > print aa.size , aa.shape >>> 1 ( ) > = () are not list delim

Re: [Numpy-discussion] About asarray (list)

2008-08-27 Thread Dag Sverre Seljebotn
Manuel Metz wrote: > Claude Gouedard wrote: >> Hi , >> >> I'm just surprised by the behaviour of numpy.asarray on lists. >> >> Can someone comment this : >> = >> a=(1) >> aa=asarray(a) >> print aa.size , aa.shape 1 ( ) >> = >> >> The shape doesnot r

Re: [Numpy-discussion] About asarray (list)

2008-08-27 Thread Manuel Metz
Claude Gouedard wrote: > Hi , > > I'm just surprised by the behaviour of numpy.asarray on lists. > > Can someone comment this : > = > a=(1) > aa=asarray(a) > print aa.size , aa.shape >>> 1 ( ) > = > > The shape doesnot reflect the actual size. Becaus

[Numpy-discussion] About asarray (list)

2008-08-27 Thread Claude Gouedard
Hi , I'm just surprised by the behaviour of numpy.asarray on lists. Can someone comment this : = a=(1) aa=asarray(a) print aa.size , aa.shape >> 1 ( ) = The shape doesnot reflect the actual size. If a=(1,2) there is no problem .

[Numpy-discussion] Array subclassing - question for Travis

2008-08-27 Thread Matthew Brett
Hi Travis and team, I am just writing some docs for subclassing, and ran into some behavior I didn't understand: In [143]: class A(np.ndarray): pass In [144]: arr = np.arange(5) In [145]: obj = arr.copy().view(A) In [146]: type(obj) Out[146]: In [147]: obj.__array_priority__ # shouldn't thi