Re: [Numpy-discussion] python reduce vs numpy reduce for outer product

2009-09-26 Thread Robert Kern
On Sat, Sep 26, 2009 at 18:17, Erik Tollerud wrote: >> I'm sure you mean np.multiply.reduce(). > Yes, sorry - typo. > >>> Or, if there's a better way to just start with the first 3 1d >>> vectorsand jump straight to the broadcast product (basically, an outer >>> product over arbitrary number of di

Re: [Numpy-discussion] python reduce vs numpy reduce for outer product

2009-09-26 Thread Erik Tollerud
> I'm sure you mean np.multiply.reduce(). Yes, sorry - typo. >> Or, if there's a better way to just start with the first 3 1d >> vectorsand jump straight to the broadcast product (basically, an outer >> product over arbitrary number of dimensions...)? > > Well, numpy doesn't support arbitrary numb

Re: [Numpy-discussion] python reduce vs numpy reduce for outer product

2009-09-26 Thread Robert Kern
On Sat, Sep 26, 2009 at 17:17, Erik Tollerud wrote: > I'm encountering behavior that I think makes sense, but I'm not sure > if there's some numpy function I'm unaware of that might speed up this > operation. > > I have a (potentially very long) sequence of vectors, but for > examples' sake, I'll

[Numpy-discussion] python reduce vs numpy reduce for outer product

2009-09-26 Thread Erik Tollerud
I'm encountering behavior that I think makes sense, but I'm not sure if there's some numpy function I'm unaware of that might speed up this operation. I have a (potentially very long) sequence of vectors, but for examples' sake, I'll stick with three: [A,B,C] with lengths na,nb, and nc. To get th

Re: [Numpy-discussion] np.any and np.all short-circuiting

2009-09-26 Thread Citi, Luca
Hello David, thank you. I followed your suggestion but I was unable to make it work. I surprisingly found that with numpy in a different folder, it worked. I am afraid it is due to the fact that the first one is not a linux filesystem and cannot deal with permission and ownership. This would make

Re: [Numpy-discussion] unpacking bytes directly in numpy

2009-09-26 Thread David Cournapeau
On Sat, Sep 26, 2009 at 10:33 PM, Thomas Robitaille wrote: > Hi, > > To convert some bytes to e.g. a 32-bit int, I can do > > bytes = f.read(4) > i = struct.unpack('>i', bytes)[0] > > and the convert it to np.int32 with > > i = np.int32(i) > > However, is there a more direct way of directly transf

[Numpy-discussion] unpacking bytes directly in numpy

2009-09-26 Thread Thomas Robitaille
Hi, To convert some bytes to e.g. a 32-bit int, I can do bytes = f.read(4) i = struct.unpack('>i', bytes)[0] and the convert it to np.int32 with i = np.int32(i) However, is there a more direct way of directly transforming bytes into a np.int32 type without the intermediate 'struct.unpack' st

Re: [Numpy-discussion] Tuple outer product?

2009-09-26 Thread Mads Ipsen
Robert Kern wrote: > On Fri, Sep 25, 2009 at 17:38, Mads Ipsen wrote: > >> Yes, but it should also work for [2.1,3.2,4.5] combined with >> [4.6,-2.3,5.6] - forgot to tell that. >> > > In [5]: np.transpose(np.meshgrid([2.1,3.2,4.5], [4.6,-2.3,5.6])) > Out[5]: > array([[[ 2.1, 4.6], >