[Numpy-discussion] Index update

Val Kalatsky kalatsky at gmail.com
Tue Jan 10 15:45:46 EST 2012


A - np.digitize(A, S)
Should do the trick, just make sure that S is sorted and A and S do not
overlap,
if they do remove those items from A using set operations.
Val

On Tue, Jan 10, 2012 at 2:14 PM, Mads Ipsen <madsipsen at gmail.com> wrote:

> **
> Hi,
>
> Suppose you have N items, say N = 10.
>
> Now a subset of these items are selected given by a list A of indices.
> Lets say that items A = [2,5,7] are selected. Assume now that you delete
> some of the items given by the indices S = [1,4,8]. This means that the
> list of indices A must be updated, since items have been deleted. For this
> particular case the updated selection list A becomes A = [1,3,5].
>
> Is there some smart numpy way of doing this index update of the selected
> items in A without looping? Typically N is large.
>
> Best regards,
>
> Mads
>
> --
> +-----------------------------------------------------+
> | Mads Ipsen                                          |
> +----------------------+------------------------------+
> | Gåsebæksvej 7, 4. tv |                              |
> | DK-2500 Valby        | phone:          +45-29716388 |
> | Denmark              | email:  mads.ipsen at gmail.com |
> +----------------------+------------------------------+
>
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120110/df087851/attachment.html>


More information about the NumPy-Discussion mailing list