Re: [Numpy-discussion] help with typemapping a C function to use numpy arrays

2009-01-06 Thread Matthieu Brucher
2009/1/6 Rich E : > This helped immensely. I feel like I am getting close to being able > to accomplish what I would like with SWIG: producing a python module > that can be very 'python-like', while co-existing with the c library > that is very 'c-like'. > > There is one question still remaining t

Re: [Numpy-discussion] record array with array elements

2009-01-06 Thread Robert Kern
On Tue, Jan 6, 2009 at 22:04, Igor Sylvester wrote: > If array fields should be of the form (name,subdtype, shape), how do I > specify field offsets? My datatype is word-aligned. With dtype(some_list), you need to explicitly include the padding. E.g. ('', '|V4') to add 4 bytes of padding. Alterna

Re: [Numpy-discussion] record array with array elements

2009-01-06 Thread Igor Sylvester
If array fields should be of the form (name,subdtype, shape), how do I specify field offsets? My datatype is word-aligned. Thanks. On Tue, Jan 6, 2009 at 3:41 PM, Robert Kern wrote: > On Tue, Jan 6, 2009 at 14:07, Igor Sylvester wrote: > > Everyone, > > > > Shouldn't the itemsize below be 2? >

Re: [Numpy-discussion] help with typemapping a C function to use numpy arrays

2009-01-06 Thread Rich E
This helped immensely. I feel like I am getting close to being able to accomplish what I would like with SWIG: producing a python module that can be very 'python-like', while co-existing with the c library that is very 'c-like'. There is one question still remaining though, is it possible to make

Re: [Numpy-discussion] record array with array elements

2009-01-06 Thread Robert Kern
On Tue, Jan 6, 2009 at 14:07, Igor Sylvester wrote: > Everyone, > > Shouldn't the itemsize below be 2? > import numpy as np dtype = np.dtype( [ (((2,), 'top'), [('nested', 'i1')]) ] ) dtype.itemsize > 1 np.__version__ > '1.0.4' > > The elements of the dtype are of type array of

Re: [Numpy-discussion] record array with array elements

2009-01-06 Thread Igor Sylvester
A simpler example returns 1 as well: np.dtype( [ (((2,), 'a'), 'i1') ] ).itemsize On Tue, Jan 6, 2009 at 2:07 PM, Igor Sylvester wrote: > Everyone, > > Shouldn't the itemsize below be 2? > > >>> import numpy as np > >>> dtype = np.dtype( [ (((2,), 'top'), [('nested', 'i1')]) ] ) > >>> dtype.ite

[Numpy-discussion] record array with array elements

2009-01-06 Thread Igor Sylvester
Everyone, Shouldn't the itemsize below be 2? >>> import numpy as np >>> dtype = np.dtype( [ (((2,), 'top'), [('nested', 'i1')]) ] ) >>> dtype.itemsize 1 >>> np.__version__ '1.0.4' The elements of the dtype are of type array of size 2. Each element is a (nested) record array of size 2 with one f

Re: [Numpy-discussion] [Newbie] Fast plotting

2009-01-06 Thread Alan G Isaac
A Tuesday 06 January 2009, Franck Pommereau escrigué: > s = {} # sum of y values for each distinct x (as keys) > n = {} # number of summed values (same keys) > for x, y in zip(X, Y) : > s[x] = s.get(x, 0.0) + y > n[x] = n.get(x, 0) + 1 Maybe this is not so bad with a couple changes? from

Re: [Numpy-discussion] [Newbie] Fast plotting

2009-01-06 Thread Sebastian Stephan Berg
Hello, Just thinking. If the parameters are limited, you may be able to use the histogram feature? Doing one histogram with Y as weights, then one without weights and calculating the mean from this yourself should be pretty speedy I imagine. Other then that maybe sorting the whole thing and then d

Re: [Numpy-discussion] [Newbie] Fast plotting

2009-01-06 Thread Bruce Southey
Francesc Alted wrote: > A Tuesday 06 January 2009, Franck Pommereau escrigué: > >> Hi all, and happy new year! >> >> I'm new to NumPy and searching a way to compute from a set of points >> (x,y) the mean value of y values associated to each distinct x value. >> Each point corresponds to a measur

Re: [Numpy-discussion] Re : [Newbie] Fast plotting

2009-01-06 Thread John Hunter
On Tue, Jan 6, 2009 at 7:38 AM, Jean-Baptiste Rudant wrote: > Hello, > I'm not an expert. Something exists in matplotlib, but it's not very > efficient. > import matplotlib.mlab > import numpy > N = 1000 > X = numpy.random.randint(0, 10, N) > Y = numpy.random.random(N) > recXY = numpy.rec.fromarr

[Numpy-discussion] Re : [Newbie] Fast plotting

2009-01-06 Thread Jean-Baptiste Rudant
Hello, I'm not an expert. Something exists in matplotlib, but it's not very efficient. import matplotlib.mlab import numpy N = 1000 X = numpy.random.randint(0, 10, N) Y = numpy.random.random(N) recXY = numpy.rec.fromarrays((X, Y), names='x, y') summary = matplotlib..mlab.rec_groupby(recXY, ('x',

Re: [Numpy-discussion] [Newbie] Fast plotting

2009-01-06 Thread Francesc Alted
A Tuesday 06 January 2009, Franck Pommereau escrigué: > Hi all, and happy new year! > > I'm new to NumPy and searching a way to compute from a set of points > (x,y) the mean value of y values associated to each distinct x value. > Each point corresponds to a measure in a benchmark (x = parameter,

Re: [Numpy-discussion] Old-style classes in tests

2009-01-06 Thread Stéfan van der Walt
Hi Tom 2008/11/24 Tom Wright : > I am currently working on the Ironclad project porting numpy to Ironpython. > > It would be quite useful for me if HermitianTestCase in test_linalg.py > was a new style-class instead of an old-style class - since Ironpython > has a bug where dir operations do not w

[Numpy-discussion] [Newbie] Fast plotting

2009-01-06 Thread Franck Pommereau
Hi all, and happy new year! I'm new to NumPy and searching a way to compute from a set of points (x,y) the mean value of y values associated to each distinct x value. Each point corresponds to a measure in a benchmark (x = parameter, y = computation time) and I'd like to plot the graph of mean co

Re: [Numpy-discussion] Handling methods of object-arrays

2009-01-06 Thread Robert Kern
On Tue, Jan 6, 2009 at 03:15, Stéfan van der Walt wrote: > Hi all, > > What is the exact protocol for evaluating functions like "real" and > "imag" on object arrays? > > For example, I'm looking at > > x = np.array([np.array(3+1j), np.array(4+1j)], dtype=object) > > For which both > > In [4]: x.r

[Numpy-discussion] Handling methods of object-arrays

2009-01-06 Thread Stéfan van der Walt
Hi all, What is the exact protocol for evaluating functions like "real" and "imag" on object arrays? For example, I'm looking at x = np.array([np.array(3+1j), np.array(4+1j)], dtype=object) For which both In [4]: x.real Out[4]: array([(3+1j), (4+1j)], dtype=object) and In [6]: np.real(x) Ou