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 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= np.r_[lengths, lengths], len

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

2012-06-03 Thread srean
Hi Wolfgang, I think you are looking for reduceat( ), in particular add.reduceat() -- srean On Thu, May 31, 2012 at 12:36 AM, Wolfgang Kerzendorf wrote: > Dear all, > > I have an ndarray which consists of many arrays stacked behind each other > (only conceptually, in truth it's a normal 1d f

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

2012-05-31 Thread Val Kalatsky
Hi Wolfgang, I thought maybe there is a trick for your specific operation. Your array stacking is a simple case of the group-by operation and normalization is aggregation followed by update. I believe group-by and aggregation are on the NumPy todo-list. You may have to write a small extension modu

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

2012-05-31 Thread Wolfgang Kerzendorf
Hey Val, Well it doesn't matter what I do, but specifically I do factor = sum(data_array[start_point:start_point+length_data]) and then data[array[start_point:start_point+length_data]) /= factor. and that for every star_point and length data. How to do this fast? Cheers Wolfgang On 2012-05-

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

2012-05-30 Thread Val Kalatsky
What do you mean by "normalized it"? Could you give the output of your procedure for the sample input data. Val On Thu, May 31, 2012 at 12:36 AM, Wolfgang Kerzendorf wrote: > Dear all, > > I have an ndarray which consists of many arrays stacked behind each other > (only conceptually, in truth it

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

2012-05-30 Thread Wolfgang Kerzendorf
Dear all, I have an ndarray which consists of many arrays stacked behind each other (only conceptually, in truth it's a normal 1d float64 array). I have a second array which tells me the start of the individual data sets in the 1d float64 array and another one which tells me the length. Example: