Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread josef . pktd
On Thu, Sep 30, 2010 at 12:07 AM, wrote: > On Wed, Sep 29, 2010 at 11:24 PM, Damien Morton > wrote: >> On Thu, Sep 30, 2010 at 11:11 AM,   wrote: bincount only works for gathering/accumulating scalars. Even the 'weights' parameter is limited to scalars. >>> >>> Do you mean that bincou

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread josef . pktd
On Wed, Sep 29, 2010 at 11:24 PM, Damien Morton wrote: > On Thu, Sep 30, 2010 at 11:11 AM,   wrote: >>> bincount only works for gathering/accumulating scalars. Even the >>> 'weights' parameter is limited to scalars. >> >> Do you mean that bincount only works with 1d arrays? I also think that >> th

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Damien Morton
>>> I propose the name 'gather()' for the helper function that does this. >> >> I don't think "gather" is an obvious name to search for. > > "gather" is the name that the GPGPU community uses to describe this > kind of operation. Not just for summation but for any kind of indexed > reducing operati

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Damien Morton
On Thu, Sep 30, 2010 at 11:11 AM, wrote: >> bincount only works for gathering/accumulating scalars. Even the >> 'weights' parameter is limited to scalars. > > Do you mean that bincount only works with 1d arrays? I also think that > this is a major limitation of it. >>> from numpy import * >>> a

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Robert Kern
On Wed, Sep 29, 2010 at 20:11, wrote: > On Wed, Sep 29, 2010 at 9:03 PM, Damien Morton wrote: >> On Thu, Sep 30, 2010 at 3:28 AM, Robert Kern wrote: >>> On Wed, Sep 29, 2010 at 12:00, Pauli Virtanen wrote: Wed, 29 Sep 2010 11:15:08 -0500, Robert Kern wrote: [clip: inplace addition wi

Re: [Numpy-discussion] Multiplying list of matrices with list of vectors

2010-09-29 Thread Charles R Harris
On Wed, Sep 29, 2010 at 1:03 PM, David Reichert wrote: > Hi, > > I have a list of matrices W_k I'd like to multiply with a list of vectors > v_k, > or another way of looking at it, writing all W_k into a 3d array and all > v_k into a 2d matrix/array, I'd like to compute matrix R as > > R_ik = sum_

Re: [Numpy-discussion] Improvements to SciPy.org Server

2010-09-29 Thread Fernando Perez
On Wed, Sep 29, 2010 at 10:48 AM, Aaron River wrote: > Greetings Gentle Folk, > > I'm happy to announce that the server hosting SciPy.org, > as well as other OSS projects, has been migrated into a > cluster assigned to our community support efforts. As someone who has been grateful, yet frustrate

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread josef . pktd
On Wed, Sep 29, 2010 at 9:03 PM, Damien Morton wrote: > On Thu, Sep 30, 2010 at 3:28 AM, Robert Kern wrote: >> On Wed, Sep 29, 2010 at 12:00, Pauli Virtanen wrote: >>> Wed, 29 Sep 2010 11:15:08 -0500, Robert Kern wrote: >>> [clip: inplace addition with duplicates] Use numpy.bincount() inste

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Damien Morton
On Thu, Sep 30, 2010 at 3:28 AM, Robert Kern wrote: > On Wed, Sep 29, 2010 at 12:00, Pauli Virtanen wrote: >> Wed, 29 Sep 2010 11:15:08 -0500, Robert Kern wrote: >> [clip: inplace addition with duplicates] >>> Use numpy.bincount() instead. >> >> It might be worthwhile to add a separate helper fun

Re: [Numpy-discussion] looking for code advice

2010-09-29 Thread Gordon Wrigley
Hi Josef Thanks for your comments. > numpy.ptp(a, axis=None, out=None) > Range of values (maximum - minimum) along an axis. I feel silly for not having noticed that function, it's right next to amin and amax in the docs. Both your suggestions improved the performance, but only a little, regardl

Re: [Numpy-discussion] numpydoc: "Other Parameters" section

2010-09-29 Thread Joe Harrington
> It seems that the "Other parameters" section is not > getting included in the output. The "Other parameters" is not often used in numpy because there are not generally dozens of "tweaking" parameters in its basic numerical routines. It will probably be more common in certain scipy pages, and i

Re: [Numpy-discussion] Appending/combining masked arrays

2010-09-29 Thread Pierre GM
On Sep 30, 2010, at 12:15 AM, Gökhan Sever wrote: > On Wed, Sep 29, 2010 at 5:09 PM, Pierre GM wrote: >> >> On Sep 29, 2010, at 11:46 PM, josef.p...@gmail.com wrote: >>> >>> any of the ma stack array function might also work, or not? >> >> In np.ma.extras ? Most likely, yes > > This seems to

Re: [Numpy-discussion] Appending/combining masked arrays

2010-09-29 Thread Pierre GM
On Sep 30, 2010, at 12:01 AM, Gökhan Sever wrote: >> You're using a standard numpy function on a masked array. It's hardly >> surprising that you run into some issues. You should use the np.ma >> equivalent. Except of course that the equivalent doesn't exist yet... Please >> open a ticket. >

Re: [Numpy-discussion] Appending/combining masked arrays

2010-09-29 Thread Gökhan Sever
On Wed, Sep 29, 2010 at 5:09 PM, Pierre GM wrote: > > On Sep 29, 2010, at 11:46 PM, josef.p...@gmail.com wrote: >> >> any of the ma stack array function might also work, or not? > > In np.ma.extras ? Most likely, yes This seems to do what I want: I[262]: np.ma.hstack(all_measured) O[262]: masked

Re: [Numpy-discussion] Appending/combining masked arrays

2010-09-29 Thread Pierre GM
On Sep 29, 2010, at 11:46 PM, josef.p...@gmail.com wrote: > > any of the ma stack array function might also work, or not? In np.ma.extras ? Most likely, yes ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/list

Re: [Numpy-discussion] Appending/combining masked arrays

2010-09-29 Thread Gökhan Sever
> You're using a standard numpy function on a masked array. It's hardly > surprising that you run into some issues. You should use the np.ma > equivalent. Except of course that the equivalent doesn't exist yet... Please > open a ticket. Here it comes -> http://projects.scipy.org/numpy/ticket/16

Re: [Numpy-discussion] Appending/combining masked arrays

2010-09-29 Thread josef . pktd
On Wed, Sep 29, 2010 at 5:37 PM, Pierre GM wrote: > > On Sep 29, 2010, at 11:01 PM, Gökhan Sever wrote: > >> Hello, >> >> Consider these two simple masked arrays: >> >> I[188]: a = np.ma.masked_equal([1,2,3], value=2) >> >> I[189]: b = np.ma.masked_equal([4,3,2], value=2) >> >> An operation like t

Re: [Numpy-discussion] Appending/combining masked arrays

2010-09-29 Thread Pierre GM
On Sep 29, 2010, at 11:01 PM, Gökhan Sever wrote: > Hello, > > Consider these two simple masked arrays: > > I[188]: a = np.ma.masked_equal([1,2,3], value=2) > > I[189]: b = np.ma.masked_equal([4,3,2], value=2) > > An operation like this voids the mask: > > I[190]: np.append(a,b) > O[190]: >

[Numpy-discussion] Appending/combining masked arrays

2010-09-29 Thread Gökhan Sever
Hello, Consider these two simple masked arrays: I[188]: a = np.ma.masked_equal([1,2,3], value=2) I[189]: b = np.ma.masked_equal([4,3,2], value=2) An operation like this voids the mask: I[190]: np.append(a,b) O[190]: masked_array(data = [1 2 3 4 3 2], mask = False, fill_valu

Re: [Numpy-discussion] numpydoc: "Other Parameters" section

2010-09-29 Thread josef . pktd
On Wed, Sep 29, 2010 at 4:39 PM, wrote: > On Wed, Sep 29, 2010 at 4:19 PM, Charles R Harris > wrote: >> >> >> On Wed, Sep 29, 2010 at 1:59 PM, Michael Droettboom wrote: >>> >>> We're having trouble using numpydoc formatted docstrings for one of our >>> own project.  It seems that the "Other par

Re: [Numpy-discussion] numpydoc: "Other Parameters" section

2010-09-29 Thread josef . pktd
On Wed, Sep 29, 2010 at 4:19 PM, Charles R Harris wrote: > > > On Wed, Sep 29, 2010 at 1:59 PM, Michael Droettboom wrote: >> >> We're having trouble using numpydoc formatted docstrings for one of our >> own project.  It seems that the "Other parameters" section is not >> getting included in the o

Re: [Numpy-discussion] numpydoc: "Other Parameters" section

2010-09-29 Thread Charles R Harris
On Wed, Sep 29, 2010 at 1:59 PM, Michael Droettboom wrote: > We're having trouble using numpydoc formatted docstrings for one of our > own project. It seems that the "Other parameters" section is not > getting included in the output. > > A grep across Numpy's own source code (git master) reveals

[Numpy-discussion] numpydoc: "Other Parameters" section

2010-09-29 Thread Michael Droettboom
We're having trouble using numpydoc formatted docstrings for one of our own project. It seems that the "Other parameters" section is not getting included in the output. A grep across Numpy's own source code (git master) reveals that this kind of section is used in only one place -- the docstri

[Numpy-discussion] Multiplying list of matrices with list of vectors

2010-09-29 Thread David Reichert
Hi, I have a list of matrices W_k I'd like to multiply with a list of vectors v_k, or another way of looking at it, writing all W_k into a 3d array and all v_k into a 2d matrix/array, I'd like to compute matrix R as R_ik = sum_j W_ijk h_jk. Is there a fast way of doing that in numpy? Regards,

[Numpy-discussion] Improvements to SciPy.org Server

2010-09-29 Thread Aaron River
Greetings Gentle Folk, I'm happy to announce that the server hosting SciPy.org, as well as other OSS projects, has been migrated into a cluster assigned to our community support efforts. The base instance itself remains relatively unchanged, but is now running atop a more capable set of servers.

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Robert Kern
On Wed, Sep 29, 2010 at 12:00, Pauli Virtanen wrote: > Wed, 29 Sep 2010 11:15:08 -0500, Robert Kern wrote: > [clip: inplace addition with duplicates] >> Use numpy.bincount() instead. > > It might be worthwhile to add a separate helper function for this > purpose. Bincount makes a copy that could b

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Pauli Virtanen
Wed, 29 Sep 2010 11:15:08 -0500, Robert Kern wrote: [clip: inplace addition with duplicates] > Use numpy.bincount() instead. It might be worthwhile to add a separate helper function for this purpose. Bincount makes a copy that could be avoided, and it is difficult to find if you don't know about

Re: [Numpy-discussion] looking for code advice

2010-09-29 Thread josef . pktd
On Wed, Sep 29, 2010 at 9:19 AM, wrote: > On Wed, Sep 29, 2010 at 8:25 AM, Gordon Wrigley wrote: >> Hi >> First the disclaimer: This is my first numpy experience, so I have next to >> no idea what I'm doing. >> I've muddled through and managed to put together some code for my current >> problem

Re: [Numpy-discussion] convert FORTRAN exponential format text to float

2010-09-29 Thread Thomas Kirk Gamble
On Wed, 2010-09-29 at 16:36 +0200, David Froger wrote: > Did you try loadtxt? I try to output something in the format 1.538D-06 > with Fortran in order to test reading it with loadtxt, but I always > get 1.538E-06. Where does the 'D' come from? No, I didn't, but I will. Preserving the 'D' isn't

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Robert Kern
On Wed, Sep 29, 2010 at 01:01, Damien Morton wrote: > lets say i have arrays: > > a = array((1,2,3,4,5)) > indices = array((1,1,1,1)) > > and i perform operation: > > a[indices] += 1 > > the result is > > array([1, 3, 3, 4, 5]) > > in other words, the duplicates in indices are ignored > > if I wan

Re: [Numpy-discussion] convert FORTRAN exponential format text to float

2010-09-29 Thread David Froger
program write_txt real(kind=8):: x open(10,file='data.txt') do i = 1,10 x = i*2. write(10,fmt='(2(D12.3))') x,x**2 enddo close(10) end program write_txt In [1]: def expDtofloat(s): ...: return float(s.replace('D','E')) ...: In [2]: x,y = loadtxt('data.txt',unpack=True,c

Re: [Numpy-discussion] convert FORTRAN exponential format text to float

2010-09-29 Thread David Froger
program write_txt real(kind=8):: x open(10,file='data.txt') do i = 1,10 x = i*2. write(10,fmt='(2(D12.3))') x,x**2 enddo close(10) end program write_txt In [1]: x,y = loadtxt('data.txt',unpack=True) --- ValueErr

Re: [Numpy-discussion] convert FORTRAN exponential format text to float

2010-09-29 Thread David Froger
Did you try loadtxt? I try to output something in the format 1.538D-06 with Fortran in order to test reading it with loadtxt, but I always get 1.538E-06. Where does the 'D' come from? ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mai

[Numpy-discussion] convert FORTRAN exponential format text to float

2010-09-29 Thread Thomas Kirk Gamble
I need to convert numbers read from a text file to floating point. The numbers are in the format 1.538D-06 (written by a FORTRAN application) and have varying amounts of whitespace between them from line to line. The function fromstring() deals with the whitespace just fine but 'dtype=float' doesn

Re: [Numpy-discussion] looking for code advice

2010-09-29 Thread josef . pktd
On Wed, Sep 29, 2010 at 8:25 AM, Gordon Wrigley wrote: > Hi > First the disclaimer: This is my first numpy experience, so I have next to > no idea what I'm doing. > I've muddled through and managed to put together some code for my current > problem and now that I have it going I'd like to hear any

[Numpy-discussion] looking for code advice

2010-09-29 Thread Gordon Wrigley
Hi First the disclaimer: This is my first numpy experience, so I have next to no idea what I'm doing. I've muddled through and managed to put together some code for my current problem and now that I have it going I'd like to hear any comments people may have on both my solution and other ways of

[Numpy-discussion] NPZ format

2010-09-29 Thread Francesc Alted
Hi, I'm going to give a seminar about serialization, and I'd like to describe the .npy format. I noticed that there is a variant of it called .npz that can pack several arrays in one single file. However, .npz does not use compression at all and I'm wondering what's the reason. I suppose tha