summaryrefslogtreecommitdiff
path: root/numpy/lib/arraysetops.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/arraysetops.py')
-rw-r--r--numpy/lib/arraysetops.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py
index 2d98c35d2..5c3b504de 100644
--- a/numpy/lib/arraysetops.py
+++ b/numpy/lib/arraysetops.py
@@ -204,8 +204,9 @@ def unique(ar, return_index=False, return_inverse=False, return_counts=False):
ret += (perm[flag],)
if return_inverse:
iflag = np.cumsum(flag) - 1
- iperm = perm.argsort()
- ret += (np.take(iflag, iperm),)
+ inv_idx = np.empty(ar.shape, dtype=np.intp)
+ inv_idx[perm] = iflag
+ ret += (inv_idx,)
if return_counts:
idx = np.concatenate(np.nonzero(flag) + ([ar.size],))
ret += (np.diff(idx),)
@@ -332,6 +333,10 @@ def in1d(ar1, ar2, assume_unique=False, invert=False):
`in1d` can be considered as an element-wise function version of the
python keyword `in`, for 1-D sequences. ``in1d(a, b)`` is roughly
equivalent to ``np.array([item in b for item in a])``.
+ However, this idea fails if `ar2` is a set, or similar (non-sequence)
+ container: As ``ar2`` is converted to an array, in those cases
+ ``asarray(ar2)`` is an object array rather than the expected array of
+ contained values.
.. versionadded:: 1.4.0