On 21 October 2017 at 21:03, Robert Kern <robert.k...@gmail.com> wrote:

> Index with a boolean mask.
>
> mask = (tmp_px > 2)
> px = tmp_px[mask]
> py = tmp_py[mask]
> # ... etc.
>
>
That isn't equivalent, note that j only increases when tmp_px > 2. I think
you can do it with something like:

mask = tmp_px > 2
j_values = np.cumsum(mask)[mask]
i_values = np.arange(len(j_values))

px[i_values] = tmp_i[j_values]
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to