Re: [Numpy-discussion] fast putmask implementation

2007-08-16 Thread Eric Firing
David M. Cooke wrote: > On Thu, Aug 16, 2007 at 04:39:02PM -1000, Eric Firing wrote: >> As far as I can see there is no way of using svn diff to deal with >> this automatically, so in the attached revision I have manually removed >> chunks resulting solely from whitespace. >> >> Is there a better

Re: [Numpy-discussion] numpy.array does not take generators

2007-08-16 Thread Robert Kern
Geoffrey Zhu wrote: > Hi All, > > I want to construct a numpy array based on Python objects. In the > below code, opts is a list of tuples. > > For example, > > opts=[ ('C', 100, 3, 'A'), ('K', 200, 5.4, 'B')] > > If I use a generator like the following: > > K=numpy.array(o[2]/1000.0 for o in

Re: [Numpy-discussion] fast putmask implementation

2007-08-16 Thread Eric Firing
David M. Cooke wrote: On Thu, Aug 16, 2007 at 04:39:02PM -1000, Eric Firing wrote: As far as I can see there is no way of using svn diff to deal with this automatically, so in the attached revision I have manually removed chunks resulting solely from whitespace. Is there a better way to handl

Re: [Numpy-discussion] fast putmask implementation

2007-08-16 Thread David M. Cooke
On Thu, Aug 16, 2007 at 04:39:02PM -1000, Eric Firing wrote: > As far as I can see there is no way of using svn diff to deal with > this automatically, so in the attached revision I have manually removed > chunks resulting solely from whitespace. > > Is there a better way to handle this problem?

Re: [Numpy-discussion] fast putmask implementation

2007-08-16 Thread Eric Firing
David Cournapeau wrote: On 8/17/07, Eric Firing <[EMAIL PROTECTED]> wrote: In looking at maskedarray performance, I found that the filled() function or method is a bottleneck. I think it can be sped up by using putmask instead of indexed assignment, but I found that putmask itself is slower tha

Re: [Numpy-discussion] fast putmask implementation

2007-08-16 Thread David Cournapeau
On 8/17/07, Eric Firing <[EMAIL PROTECTED]> wrote: > In looking at maskedarray performance, I found that the filled() > function or method is a bottleneck. I think it can be sped up by using > putmask instead of indexed assignment, but I found that putmask itself > is slower than it needs to be.

Re: [Numpy-discussion] numpy.array does not take generators

2007-08-16 Thread Alan G Isaac
On Thu, 16 Aug 2007, Geoffrey Zhu apparently wrote: > K=numpy.array(o[2]/1000.0 for o in opts) > It does not work. K=numpy.fromiter((o[2]/1000.0 for o in opts),'float') hth, Alan Isaac ___ Numpy-discussion mailing list Numpy-discussion@scipy.org ht

[Numpy-discussion] numpy.array does not take generators

2007-08-16 Thread Geoffrey Zhu
Hi All, I want to construct a numpy array based on Python objects. In the below code, opts is a list of tuples. For example, opts=[ ('C', 100, 3, 'A'), ('K', 200, 5.4, 'B')] If I use a generator like the following: K=numpy.array(o[2]/1000.0 for o in opts) It does not work. I have to use: nu

[Numpy-discussion] fast putmask implementation

2007-08-16 Thread Eric Firing
In looking at maskedarray performance, I found that the filled() function or method is a bottleneck. I think it can be sped up by using putmask instead of indexed assignment, but I found that putmask itself is slower than it needs to be. So I followed David Cournapeau's example of fastclip an

[Numpy-discussion] Finding a row match within a numpy array

2007-08-16 Thread Andy Cheesman
Dear nice people I'm trying to match a row (b) within a large numpy array (a). My most successful attempt is below hit = equal(b, a) total_hits = add.reduce(hit, 1) max_hit = argmax(total_hits, 0) answer = a[max_hit] where ... a = array([[ 0, 1, 2, 3], [ 4, 5, 6, 7],

Re: [Numpy-discussion] .transpose() of memmap array fails to close()

2007-08-16 Thread Glen W. Mabey
On Wed, Aug 15, 2007 at 08:50:28PM -0400, Anne Archibald wrote: > You have to be a bit careful, because a view really is just a view > into the array - the original is still around. So you can't really > delete the array contents when the view is deleted. Really, if you do: > B = A[::2] > del B > n

Re: [Numpy-discussion] deleting value from array

2007-08-16 Thread Nadav Horesh
The closest I can think of is: a = a[range(len(a)) != 1] Nadav. On Wed, 2007-08-15 at 02:07 -0700, mark wrote: > I am trying to delete a value from an array > This seems to work as follows > > >>> a = array([1,2,3,4]) > >>> a = delete( a, 1 ) > >>> a > array([1, 3, 4]) > > But wouldn't it