[Numpy-discussion] efficient way to do this?

2008-09-22 Thread John Hunter
I have a an array of indices into a larger array where some condition is satisfied. I want to create a larger set of indices which *mark* all the indicies following the condition over some Nmark length window. In code: import numpy as np N = 1000 Nmark = 20 ind =

Re: [Numpy-discussion] efficient way to do this?

2008-09-22 Thread Fabrice Silva
Le lundi 22 septembre 2008 à 09:41 -0500, John Hunter a écrit : I have a an array of indices into a larger array where some condition is satisfied. I want to create a larger set of indices which *mark* all the indicies following the condition over some Nmark length window. A =

Re: [Numpy-discussion] efficient way to do this?

2008-09-22 Thread Robert Kern
On Mon, Sep 22, 2008 at 09:41, John Hunter [EMAIL PROTECTED] wrote: I have a an array of indices into a larger array where some condition is satisfied. I want to create a larger set of indices which *mark* all the indicies following the condition over some Nmark length window. In code:

Re: [Numpy-discussion] efficient way to do this?

2008-09-22 Thread John Hunter
On Mon, Sep 22, 2008 at 10:13 AM, Robert Kern [EMAIL PROTECTED] wrote: marked[ind + np.arange(Nmark)] = True That triggers a broadcasting error: Traceback (most recent call last): File /home/titan/johnh/test.py, line 13, in ? marked3[ind + np.arange(Nmark)] = True ValueError: shape

Re: [Numpy-discussion] efficient way to do this?

2008-09-22 Thread Robert Kern
On Mon, Sep 22, 2008 at 10:22, Robert Kern [EMAIL PROTECTED] wrote: ind2mark = np.asarray((ind[:,np.newaxis] + np.arange(Nmark).flat).clip(0, N-1) marked[ind2mark] = True Missing parenthesis: ind2mark = np.asarray((ind[:,np.newaxis] + np.arange(Nmark)).flat).clip(0, N-1) -- Robert Kern I

Re: [Numpy-discussion] efficient way to do this?

2008-09-22 Thread John Hunter
On Mon, Sep 22, 2008 at 10:23 AM, Robert Kern [EMAIL PROTECTED] wrote: On Mon, Sep 22, 2008 at 10:22, Robert Kern [EMAIL PROTECTED] wrote: ind2mark = np.asarray((ind[:,np.newaxis] + np.arange(Nmark).flat).clip(0, N-1) marked[ind2mark] = True Missing parenthesis: ind2mark =