[Numpy-discussion] efficient way to do this?

John Hunter jdh2358 at gmail.com
Mon Sep 22 11:25:15 EDT 2008


On Mon, Sep 22, 2008 at 10:23 AM, Robert Kern <robert.kern at gmail.com> wrote:
> On Mon, Sep 22, 2008 at 10:22, Robert Kern <robert.kern at gmail.com> 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)

Excellent, thanks!  Note to self, must become a newaxis guru...

JDH



More information about the NumPy-Discussion mailing list