[Numpy-discussion] Slices from an index list

2012-04-11 Thread Mads Ipsen
Hi, Suppose a have an array of indices, say indices = [0,1,2,3,5,7,8,9,10,12,13,14] Then the following slices a = slice(0,4) b = slice(4,5) c = slice(5,9) d = slice(9,12) provide information about all the consecutive parts of the index list. Given the list of indices, is there some

Re: [Numpy-discussion] Slices from an index list

2012-04-11 Thread Warren Weckesser
On Wed, Apr 11, 2012 at 4:28 AM, Mads Ipsen wrote: > Hi, > > Suppose a have an array of indices, say > > indices = [0,1,2,3,5,7,8,9,10,12,13,14] > > Then the following slices > > a = slice(0,4) > b = slice(4,5) > c = slice(5,9) > d = slice(9,12) > > provide information about all the co

Re: [Numpy-discussion] Slices from an index list

2012-04-11 Thread Zachary Pincus
> Here's one way you could do it: > > In [43]: indices = [0,1,2,3,5,7,8,9,10,12,13,14] > > In [44]: jumps = where(diff(indices) != 1)[0] + 1 > > In [45]: starts = hstack((0, jumps)) > > In [46]: ends = hstack((jumps, len(indices))) > > In [47]: slices = [slice(start, end) for start, end in zip

Re: [Numpy-discussion] Slices from an index list

2012-04-11 Thread Mads Ipsen
On 11/04/2012 13:42, Warren Weckesser wrote: On Wed, Apr 11, 2012 at 4:28 AM, Mads Ipsen > wrote: Hi, Suppose a have an array of indices, say indices = [0,1,2,3,5,7,8,9,10,12,13,14] Then the following slices a = slice(0,4) b = slic

Re: [Numpy-discussion] Slices from an index list

2012-04-11 Thread Mads Ipsen
On 11/04/2012 14:19, Zachary Pincus wrote: Here's one way you could do it: In [43]: indices = [0,1,2,3,5,7,8,9,10,12,13,14] In [44]: jumps = where(diff(indices) != 1)[0] + 1 In [45]: starts = hstack((0, jumps)) In [46]: ends = hstack((jumps, len(indices))) In [47]: slices = [slice(start, end

[Numpy-discussion] RuntimeWarning: numpy.ndarray size changed

2012-04-11 Thread Nils Wagner
Hi all, Can someone reproduce the following message ? Python 2.7.2 (default, Aug 19 2011, 20:41:43) [GCC] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy /home/nwagner/local/lib64/python2.7/site-packages/numpy/random/__init__.py:91: RuntimeWarn

Re: [Numpy-discussion] RuntimeWarning: numpy.ndarray size changed

2012-04-11 Thread Charles R Harris
On Wed, Apr 11, 2012 at 12:45 PM, Nils Wagner wrote: > Hi all, > > Can someone reproduce the following message ? > > Python 2.7.2 (default, Aug 19 2011, 20:41:43) [GCC] on > linux2 > Type "help", "copyright", "credits" or "license" for more > information. > >>> import numpy > > /home/nwagner/local

Re: [Numpy-discussion] RuntimeWarning: numpy.ndarray size changed

2012-04-11 Thread Charles R Harris
On Wed, Apr 11, 2012 at 1:11 PM, Charles R Harris wrote: > > > On Wed, Apr 11, 2012 at 12:45 PM, Nils Wagner < > nwag...@iam.uni-stuttgart.de> wrote: > >> Hi all, >> >> Can someone reproduce the following message ? >> >> Python 2.7.2 (default, Aug 19 2011, 20:41:43) [GCC] on >> linux2 >> Type "he

Re: [Numpy-discussion] Masked Arrays in NumPy 1.x

2012-04-11 Thread Paul Hobson
Travis et al, This isn't a reply to anything specific in your email and I apologize if there is a better thread or place to share this information. I've been meaning to participate in the discussion for a long time and never got around to it. The main thing I'd like to is convey my typical use of

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-11 Thread Dag Sverre Seljebotn
On 04/10/2012 02:11 AM, Travis Oliphant wrote: > Hi all, > > Some of you are aware of Numba. Numba allows you to create the equivalent > of C-function's dynamically from Python. One purpose of this system is to > allow NumPy to take these functions and use them in operations like ufuncs, > g

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-11 Thread Travis Oliphant
> On 04/10/2012 02:11 AM, Travis Oliphant wrote: >> Hi all, >> >> Some of you are aware of Numba. Numba allows you to create the equivalent >> of C-function's dynamically from Python. One purpose of this system is to >> allow NumPy to take these functions and use them in operations like ufu

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-11 Thread Dag Sverre Seljebotn
On 04/11/2012 11:00 PM, Travis Oliphant wrote: > >> On 04/10/2012 02:11 AM, Travis Oliphant wrote: >>> Hi all, >>> >>> Some of you are aware of Numba. Numba allows you to create the equivalent >>> of C-function's dynamically from Python. One purpose of this system is to >>> allow NumPy to tak

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-11 Thread Travis Oliphant
Thoughts? >>> >>> I really hope we can find some project-neutral common ground, so that lots >>> of tools (Cython, f2py, numba, C extensions in NumPy and SciPy) can agree >>> on how to "unbox callables". >>> >>> A new extension type in NumPy would not fit this bill I feel. I've created >>

[Numpy-discussion] mask array and add to list

2012-04-11 Thread questions anon
I am trying to mask an array and then add the array to a list, so I can then go on and calculate the max, min and mean of that list. The mask seems to work when I check each array. I check each array by finding the max, mean and mean and comparing with the unmasked array (they are different). Howev

[Numpy-discussion] partial computations

2012-04-11 Thread santhu kumar
Hello all, I am trying to optimise a code and want your suggestions. A : - NX3 matrix (coordinates of N points) After performing pairwise distance computations(called pdist) between these points, depending upon a condition that the distance is in, I would perform further computations. Most of the