[Numpy-discussion] unique1d returning indices
Robert Cimrman
cimrman3 at ntc.zcu.cz
Wed Aug 6 08:52:38 EDT 2008
Hi,
due to popular demand, I have updated unique1d() to optionally return
both kinds of indices:
In [3]: b, i, j = nm.unique1d( a, return_index=True, return_inverse=True )
In [4]: a
Out[4]: array([1, 1, 8, 3, 3, 5, 4])
In [6]: b
Out[6]: array([1, 3, 4, 5, 8])
In [7]: a[i]
Out[7]: array([1, 3, 4, 5, 8])
In [8]: b[j]
Out[8]: array([1, 1, 8, 3, 3, 5, 4])
In [9]: a
Out[9]: array([1, 1, 8, 3, 3, 5, 4])
Could someone needing this try the attached code? If it is ok I will
update the tests, the docstring and commit it.
Note also that the order of outputs has changed (previously unique1d()
returned (i, b) for return_index=True).
cheers,
r.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unique1d.py
Type: text/x-python
Size: 2055 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080806/53eb9ade/attachment.py>
More information about the NumPy-Discussion
mailing list