Re: [Numpy-discussion] numpy ufuncs and COREPY - any info?

2009-05-27 Thread Francesc Alted
A Tuesday 26 May 2009 15:14:39 Andrew Friedley escrigué: > David Cournapeau wrote: > > Francesc Alted wrote: > >> Well, it is Andrew who should demonstrate that his measurement is > >> correct, but in principle, 4 cycles/item *should* be feasible when using > >> 8 cores in parallel. > > > > But the

Re: [Numpy-discussion] Benchmak on record arrays

2009-05-27 Thread Charles R Harris
On Wed, May 27, 2009 at 1:21 PM, Nicolas Rougier wrote: > > > No, I don't have permission to edit. > Nicolas > You should ask for it then. Email stephan at . The docs are here . Chuck ___ Numpy-discussion mai

Re: [Numpy-discussion] Nested recarrays with subarrays and loadtxt: a bug in loadtxt?

2009-05-27 Thread Fernando Perez
2009/5/27 Stéfan van der Walt : > Hi Fernando > > 2009/5/28 Fernando Perez : >> Well, since dtypes allow for nesting full arrays in this fashion, >> where I can say that the 'block' field can have (2,3) shape, it seems >> like it would be nice to be able to express this nesting into loading >> of p

Re: [Numpy-discussion] Nested recarrays with subarrays and loadtxt: a bug in loadtxt?

2009-05-27 Thread Stéfan van der Walt
Hi Fernando 2009/5/28 Fernando Perez : > Well, since dtypes allow for nesting full arrays in this fashion, > where I can say that the 'block' field can have (2,3) shape, it seems > like it would be nice to be able to express this nesting into loading > of plain text files as well. I think that wo

Re: [Numpy-discussion] Nested recarrays with subarrays and loadtxt: a bug in loadtxt?

2009-05-27 Thread Pierre GM
On May 27, 2009, at 7:10 PM, Fernando Perez wrote: > Hi Pierre, > > On Wed, May 27, 2009 at 4:03 PM, Pierre GM > wrote: >> Oh yes indeed. Yet another case of "I-opened-my-mouth-too-soon'... >> >> OK, so there's a trick. Kinda: >> * Define a specific converter: >> > > Thanks, that's an alternat

Re: [Numpy-discussion] Nested recarrays with subarrays and loadtxt: a bug in loadtxt?

2009-05-27 Thread Fernando Perez
Hi Pierre, On Wed, May 27, 2009 at 4:03 PM, Pierre GM wrote: > Oh yes indeed. Yet another case of "I-opened-my-mouth-too-soon'... > > OK, so there's a trick. Kinda: > * Define a specific converter: > Thanks, that's an alternative, though I think I prefer my two-pass hack, though I can't quite re

Re: [Numpy-discussion] Nested recarrays with subarrays and loadtxt: a bug in loadtxt?

2009-05-27 Thread Fernando Perez
Hi Stefan, 2009/5/27 Stéfan van der Walt : > Hi Fernando > > 2009/5/27 Fernando Perez : >> I'm wondering if the code below illustrates a bug in loadtxt, or just >> a 'live with it' limitation. > > I'm not sure whether this is a bug or not. > > By specifying the dtype > >> dt = dtype(dict(names=['n

Re: [Numpy-discussion] Nested recarrays with subarrays and loadtxt: a bug in loadtxt?

2009-05-27 Thread Pierre GM
On May 27, 2009, at 6:15 PM, Fernando Perez wrote: > Hi Pierre, > > On Wed, May 27, 2009 at 3:01 PM, Pierre GM > wrote: >> Have you tried np.lib.io.genfromtxt ? >> > > I didn't know about it, but it has the same problem as loadtxt: Oh yes indeed. Yet another case of "I-opened-my-mouth-too-soo

Re: [Numpy-discussion] Nested recarrays with subarrays and loadtxt: a bug in loadtxt?

2009-05-27 Thread Stéfan van der Walt
Hi Fernando 2009/5/27 Fernando Perez : > I'm wondering if the code below illustrates a bug in loadtxt, or just > a 'live with it' limitation. I'm not sure whether this is a bug or not. By specifying the dtype > dt = dtype(dict(names=['name','x','y','block'], >formats=['S4',float

Re: [Numpy-discussion] Numpy vs PIL in image statistics

2009-05-27 Thread Robert Kern
On Wed, May 27, 2009 at 10:33, cp wrote: > Testing the PIL vs numpy in calculating the mean value of each color channel > of > an image I timed the following. > > impil = Image.open("10.tif") > imnum = asarray(impil) > > #in PIL > for i in range(1,10): >    stats = ImageStat.Stat(impil) >    stat

Re: [Numpy-discussion] Nested recarrays with subarrays and loadtxt: a bug in loadtxt?

2009-05-27 Thread Fernando Perez
Hi Pierre, On Wed, May 27, 2009 at 3:01 PM, Pierre GM wrote: > Have you tried np.lib.io.genfromtxt ? > I didn't know about it, but it has the same problem as loadtxt: In [5]: rdata.block[0,1] # incorrect Out[5]: array([1, 1, 1]) In [6]: alt_data.block[0,1] # same thing, still wrong Out[6]: a

Re: [Numpy-discussion] Nested recarrays with subarrays and loadtxt: a bug in loadtxt?

2009-05-27 Thread Pierre GM
On May 27, 2009, at 5:53 PM, Fernando Perez wrote: > Howdy, > > I'm wondering if the code below illustrates a bug in loadtxt, or just > a 'live with it' limitation. Have you tried np.lib.io.genfromtxt ? dt = dtype(dict(names=['name','x','y','block'], formats=['S4',float,float,(

[Numpy-discussion] Nested recarrays with subarrays and loadtxt: a bug in loadtxt?

2009-05-27 Thread Fernando Perez
Howdy, I'm wondering if the code below illustrates a bug in loadtxt, or just a 'live with it' limitation. I'm inlining it for ease of discussion, but the same code is attached to ensure that anyone willing to look at this can just download and run without pasting/whitespace issues. The code is,

Re: [Numpy-discussion] arrray/matrix nonzero() type

2009-05-27 Thread Nathan Bell
On Wed, May 27, 2009 at 3:26 PM, Nicolas Rougier wrote: > > Hi again, > > I  have a problem with the nonzero() function for matrix. > > The following test program: > > import numpy, scipy.sparse > > Z = numpy.zeros((10,10)) > > i = Z.nonzero() > print i > Zc = scipy.sparse.coo_matrix((Z[i],i)) > >

[Numpy-discussion] arrray/matrix nonzero() type

2009-05-27 Thread Nicolas Rougier
Hi again, I have a problem with the nonzero() function for matrix. The following test program: import numpy, scipy.sparse Z = numpy.zeros((10,10)) Z[0,0] = Z[1,1] = 1 i = Z.nonzero() print i Zc = scipy.sparse.coo_matrix((Z[i],i)) Z = numpy.matrix(Z) i = Z.nonzero() print i Zc = scipy.sparse

Re: [Numpy-discussion] Benchmak on record arrays

2009-05-27 Thread Nicolas Rougier
No, I don't have permission to edit. Nicolas On 27 May, 2009, at 18:01 , Charles R Harris wrote: On Wed, May 27, 2009 at 9:31 AM, Nicolas Rougier > wrote: Hi, I've written a very simple benchmark on recarrays: import numpy, time Z = numpy.zeros((100,100), dtype=numpy.float64) Z_fast

Re: [Numpy-discussion] asarray() and PIL

2009-05-27 Thread Christopher Barker
cp wrote: >>> arr=asarray(img) >>> arr.shape >>> (1600,1900,3) > >> No, it means that you have 1600 rows, 1900 columns and 3 colour channels. > > According to scipy documentation at > http://pages.physics.cornell.edu/~myers/teaching/ComputationalMethods/python/arrays.html > you are right. > > In

Re: [Numpy-discussion] Benchmak on record arrays

2009-05-27 Thread Charles R Harris
On Wed, May 27, 2009 at 9:31 AM, Nicolas Rougier wrote: > > Hi, > > I've written a very simple benchmark on recarrays: > > import numpy, time > > Z = numpy.zeros((100,100), dtype=numpy.float64) > Z_fast = numpy.zeros((100,100), dtype=[('x',numpy.float64), > ('y',numpy.int32)]) > Z_slow = numpy.zer

Re: [Numpy-discussion] asarray() and PIL

2009-05-27 Thread cp
> > arr=asarray(img) > > arr.shape > > (1600,1900,3) > No, it means that you have 1600 rows, 1900 columns and 3 colour channels. According to scipy documentation at http://pages.physics.cornell.edu/~myers/teaching/ComputationalMethods/python/arrays.html you are right. In this case I import numpy

[Numpy-discussion] Numpy vs PIL in image statistics

2009-05-27 Thread cp
Testing the PIL vs numpy in calculating the mean value of each color channel of an image I timed the following. impil = Image.open("10.tif") imnum = asarray(impil) #in PIL for i in range(1,10): stats = ImageStat.Stat(impil) stats.mean # for numpy for i in range(1,10): imnum.resha

[Numpy-discussion] Benchmak on record arrays

2009-05-27 Thread Nicolas Rougier
Hi, I've written a very simple benchmark on recarrays: import numpy, time Z = numpy.zeros((100,100), dtype=numpy.float64) Z_fast = numpy.zeros((100,100), dtype=[('x',numpy.float64), ('y',numpy.int32)]) Z_slow = numpy.zeros((100,100), dtype=[('x',numpy.float64), ('y',numpy.bool)]) t = time.cloc

Re: [Numpy-discussion] suggestion for generalizing numpy functions

2009-05-27 Thread Darren Dale
Now that numpy-1.3 has been released, I was hoping I could engage the numpy developers and community concerning my suggestion to improve the ufunc wrapping mechanism. Currently, ufuncs call, on the way out, the __array_wrap__ method of the input array with the highest __array_priority__. There are

Re: [Numpy-discussion] asarray() and PIL

2009-05-27 Thread Sebastian Haase
On Wed, May 27, 2009 at 5:12 PM, cp wrote: > Hi, > I'm using PIL for image processing, but lately I also try numpy for the > flexibility and superior speed it offers. The first thing I noticed is that > for > an RGB image with height=1600 and width=1900 while > > img=Image.open('something.tif') >

Re: [Numpy-discussion] asarray() and PIL

2009-05-27 Thread Stéfan van der Walt
2009/5/27 cp : > img=Image.open('something.tif') > img.size > (1900,1600) > > then > > arr=asarray(img) > arr.shape > (1600,1900,3) > > This means that the array-image has 1600 color channels, 1900 image pixel rows > and 3 image pixel columns. Why is that? No, it means that you have 1600 rows, 190

[Numpy-discussion] asarray() and PIL

2009-05-27 Thread cp
Hi, I'm using PIL for image processing, but lately I also try numpy for the flexibility and superior speed it offers. The first thing I noticed is that for an RGB image with height=1600 and width=1900 while img=Image.open('something.tif') img.size (1900,1600) then arr=asarray(img) arr.shape (160

Re: [Numpy-discussion] casting bug

2009-05-27 Thread Charles سمير Doutriaux
Thanks Robert, I thought it was something like that but couldn't figure it out. C. On May 26, 2009, at 4:50 PM, Robert Kern wrote: > 2009/5/26 Charles سمير Doutriaux : >> Hi there, >> >> One of our users just found a bug in numpy that has to do with >> casting. >> >> Consider the attached exam

Re: [Numpy-discussion] Failure with 1.3

2009-05-27 Thread Charles R Harris
On Wed, May 27, 2009 at 7:51 AM, Matthieu Brucher < matthieu.bruc...@gmail.com> wrote: > Hi, > > I've just tested the latest numpy with my new configuration (Opteron > 2220, 64bits with RH5.2, compiled with ICC 10.1.018) and I got this > failure. > > ===

[Numpy-discussion] Failure with 1.3

2009-05-27 Thread Matthieu Brucher
Hi, I've just tested the latest numpy with my new configuration (Opteron 2220, 64bits with RH5.2, compiled with ICC 10.1.018) and I got this failure. == FAIL: test_umath.TestLogAddExp2.test_logaddexp2_values [...] assert_almo

[Numpy-discussion] Best way to inherit from PyArrayIterObject at the C level ?

2009-05-27 Thread David Cournapeau
Hi, I have been scratching my head on the following problem. I am designing a new array iterator, in C, to walk into a neighborhood of an array. I would like this iterator to 'inherit' from PyArrayIterObject, so that I can design some API which accept both PyArrayIterObject and PyArrayNeighIte

Re: [Numpy-discussion] List/location of consecutive integers (2)

2009-05-27 Thread Bruce Southey
Christopher Barker wrote: > Andrea Gavana wrote: > >> I have tried the solutions proposed in the previous thread and it >> looks like Chris' one is the fastest for my purposes. >> > > whoo hoo! What do I win? ;-) > > >> Splitting the reading process between 4 processes will require t