Re: [Numpy-discussion] fast access and normalizing of ndarray slices

2012-06-04 Thread eat
Hi, On Mon, Jun 4, 2012 at 12:44 AM, srean srean.l...@gmail.com wrote: Hi Wolfgang, I think you are looking for reduceat( ), in particular add.reduceat() Indeed OP could utilize add.reduceat(...), like: # tst.py import numpy as np def reduce(data, lengths): ind, ends=

Re: [Numpy-discussion] better error message possible?

2012-06-04 Thread Thouis (Ray) Jones
On Fri, Jun 1, 2012 at 6:56 PM, Chris Withers ch...@simplistix.co.uk wrote: On 01/06/2012 16:39, Benjamin Root wrote:       import numpy       numpy.zeros(10)[-123]       Traceback (most recent call last):         File stdin, line 1, in module       IndexError: index out of bounds      

Re: [Numpy-discussion] better error message possible?

2012-06-04 Thread Paul Anton Letnes
On 4. juni 2012, at 16:27, Thouis (Ray) Jones wrote: On Fri, Jun 1, 2012 at 6:56 PM, Chris Withers ch...@simplistix.co.uk wrote: On 01/06/2012 16:39, Benjamin Root wrote: import numpy numpy.zeros(10)[-123] Traceback (most recent call last): File stdin, line

Re: [Numpy-discussion] Issue tracking

2012-06-04 Thread Ralf Gommers
On Sun, Jun 3, 2012 at 10:06 PM, Charles R Harris charlesr.har...@gmail.com wrote: Hi All, The issue tracking discussion seems to have died. Since github issues looks to be a viable alternative at this point, I propose to turn it on for the numpy repository and start directing people in

Re: [Numpy-discussion] Issue tracking

2012-06-04 Thread Charles R Harris
On Mon, Jun 4, 2012 at 9:34 AM, Ralf Gommers ralf.gomm...@googlemail.comwrote: On Sun, Jun 3, 2012 at 10:06 PM, Charles R Harris charlesr.har...@gmail.com wrote: Hi All, The issue tracking discussion seems to have died. Since github issues looks to be a viable alternative at this point,

Re: [Numpy-discussion] How to remove any row or column of a numpy matrix whose sum is 3?

2012-06-04 Thread Robert Kern
On Mon, Jun 4, 2012 at 5:21 PM, bob tnur bobtnu...@gmail.com wrote: Hello every body. I am new to python. How to remove any row or column of a numpy matrix whose sum is 3. To obtain and save new matrix P with (sum(anyrow)!=3 and sum(anycolumn)!=3 elements. I tried like this: P =

Re: [Numpy-discussion] How to remove any row or column of a numpy matrix whose sum is 3?

2012-06-04 Thread Chris Barker
On Mon, Jun 4, 2012 at 9:21 AM, bob tnur bobtnu...@gmail.com wrote: Hello every body. I am new to python. How to remove any row or column of a numpy matrix whose sum is 3. To obtain and save new matrix P with (sum(anyrow)!=3 and sum(anycolumn)!=3 elements. well, one question is -- do you want

[Numpy-discussion] 1D array sorting ascending and descending by fields

2012-06-04 Thread Patrick Redmond
Hi! I have a one-dimensional ndarray with two fields. I'd like to sort in descending order by field 'a', breaking ties by sorting in ascending order by field 'b'. I've found combinations of sorting and reversing followed by stable sorting that work, but there must be a straightforward way to do

Re: [Numpy-discussion] Issue tracking

2012-06-04 Thread Travis Oliphant
There is an interesting project called http://huboard.com/The projects suggests using a few Column Labels that provides a nice card-based window onto the Github issues. I have turned on issue tracking and started a few labels. Feel free to add more / adjust the names as appropriate.

Re: [Numpy-discussion] 1D array sorting ascending and descending by fields

2012-06-04 Thread Patrick Redmond
Here's how I sorted primarily by field 'a' descending and secondarily by field 'b' ascending: (Note that 'a' is the second column, 'b' is the first) data array([('b', 0.03), ('c', 0.03), ('f', 0.03), ('e', 0.01), ('d', 0.04), ('a', 0.04)], dtype=[('b',

Re: [Numpy-discussion] Changes in PyArray_FromAny between 1.5.x and 1.6.x

2012-06-04 Thread Mike Hansen
On Mon, May 28, 2012 at 3:15 AM, Mike Hansen mhan...@gmail.com wrote: In trying to upgrade NumPy within Sage, we notices some differences in behavior between 1.5 and 1.6.  In particular, in 1.5, we have sage: f = 0.5 sage: f.__array_interface__ {'typestr': '=f8'} sage: numpy.array(f)

[Numpy-discussion] Numpy + SWIG

2012-06-04 Thread Gideon Simpson
There are two types of swig problems that I was hoping to get some help with. First, suppose I have some C function void f(double *x, int nx, double *y, int ny); where we input one array, and we output another array, both of which should be the same size. I have used in my .i file:

Re: [Numpy-discussion] better error message possible?

2012-06-04 Thread Thouis (Ray) Jones
On Mon, Jun 4, 2012 at 4:27 PM, Thouis (Ray) Jones tho...@gmail.com wrote: On Fri, Jun 1, 2012 at 6:56 PM, Chris Withers ch...@simplistix.co.uk wrote: On 01/06/2012 16:39, Benjamin Root wrote:       import numpy       numpy.zeros(10)[-123]       Traceback (most recent call last):        

Re: [Numpy-discussion] better error message possible?

2012-06-04 Thread Nathaniel Smith
On Mon, Jun 4, 2012 at 10:00 PM, Thouis (Ray) Jones tho...@gmail.com wrote: On Mon, Jun 4, 2012 at 4:27 PM, Thouis (Ray) Jones tho...@gmail.com wrote: I could look into this.  There are only ~10 places the code generates this error, so it should be a pretty minor change. My initial estimate

Re: [Numpy-discussion] 1D array sorting ascending and descending by fields

2012-06-04 Thread Chris Barker
On Mon, Jun 4, 2012 at 11:10 AM, Patrick Redmond plredm...@gmail.com wrote: Here's how I sorted primarily by field 'a' descending and secondarily by field 'b' ascending: could you multiply the numeric field by -1, sort, then put it back -- somethign like: data *- -1 data_sorted = np.sort(data,

Re: [Numpy-discussion] [EXTERNAL] Numpy + SWIG

2012-06-04 Thread Bill Spotz
Gideon, For these use cases, you will need to write short wrapper functions yourself. In the online docs, http://docs.scipy.org/doc/numpy/reference/swig.interface-file.html in the section entitled Beyond the Provided Typemaps, subsection A Common Example, there is an example of how to do

Re: [Numpy-discussion] 1D array sorting ascending and descending by fields

2012-06-04 Thread Benjamin Root
On Monday, June 4, 2012, Chris Barker wrote: On Mon, Jun 4, 2012 at 11:10 AM, Patrick Redmond plredm...@gmail.comjavascript:; wrote: Here's how I sorted primarily by field 'a' descending and secondarily by field 'b' ascending: could you multiply the numeric field by -1, sort, then put

Re: [Numpy-discussion] Changes in PyArray_FromAny between 1.5.x and 1.6.x

2012-06-04 Thread Travis Oliphant
Can you raise an issue on the Github issue tracker for NumPy? These issues will be looked at more closely. This kind of change should not have made it in to the release. off-topic Given the lack of availability of time from enough experts in NumPy, this is the sort of thing that can

Re: [Numpy-discussion] some typestrings not recognized anymore

2012-06-04 Thread Travis Oliphant
Using the 'h2' is redundant, but it should not have been changed so quickly. I could see raising a deprecation warning and communicating the correct spelling ('i2'). -Travis On Jun 3, 2012, at 6:45 PM, Benjamin Root wrote: On Sunday, June 3, 2012, Ralf Gommers wrote: On Sun,

Re: [Numpy-discussion] Changes in PyArray_FromAny between 1.5.x and 1.6.x

2012-06-04 Thread Mike Hansen
On Mon, Jun 4, 2012 at 9:30 PM, Travis Oliphant tra...@continuum.io wrote: Can you raise an issue on the Github issue tracker for NumPy?   These issues will be looked at more closely.   This kind of change should not have made it in to the release. Thanks Travis! I've made this