diff options
author | zjpoh <poh.zijie@gmail.com> | 2019-09-26 22:04:11 -0700 |
---|---|---|
committer | zjpoh <poh.zijie@gmail.com> | 2019-09-26 22:04:11 -0700 |
commit | 27332a8b2b098a519e8ade0706e1ae4086f15b92 (patch) | |
tree | 4d28425c7df1fa9127a8f1cd9a3c04f449fb35e2 /numpy/lib/arraysetops.py | |
parent | f779af07a92cb419b964316960a1b503df9b712d (diff) | |
parent | 68bd6e359a6b0863acf39cad637e1444d78eabd0 (diff) | |
download | numpy-27332a8b2b098a519e8ade0706e1ae4086f15b92.tar.gz |
Merge branch 'master' into from_string_complex
Diffstat (limited to 'numpy/lib/arraysetops.py')
-rw-r--r-- | numpy/lib/arraysetops.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py index b53d8c03f..2309f7e42 100644 --- a/numpy/lib/arraysetops.py +++ b/numpy/lib/arraysetops.py @@ -213,6 +213,7 @@ def unique(ar, return_index=False, return_inverse=False, ----- When an axis is specified the subarrays indexed by the axis are sorted. This is done by making the specified axis the first dimension of the array + (move the axis to the first dimension to keep the order of the other axes) and then flattening the subarrays in C order. The flattened subarrays are then viewed as a structured type with each element given a label, with the effect that we end up with a 1-D array of structured types that can be @@ -264,7 +265,7 @@ def unique(ar, return_index=False, return_inverse=False, # axis was specified and not None try: - ar = np.swapaxes(ar, axis, 0) + ar = np.moveaxis(ar, axis, 0) except np.AxisError: # this removes the "axis1" or "axis2" prefix from the error message raise np.AxisError(axis, ar.ndim) @@ -285,7 +286,7 @@ def unique(ar, return_index=False, return_inverse=False, def reshape_uniq(uniq): uniq = uniq.view(orig_dtype) uniq = uniq.reshape(-1, *orig_shape[1:]) - uniq = np.swapaxes(uniq, 0, axis) + uniq = np.moveaxis(uniq, 0, axis) return uniq output = _unique1d(consolidated, return_index, @@ -383,6 +384,7 @@ def intersect1d(ar1, ar2, assume_unique=False, return_indices=False): To return the indices of the values common to the input arrays along with the intersected values: + >>> x = np.array([1, 1, 2, 3, 4]) >>> y = np.array([2, 1, 4, 6]) >>> xy, x_ind, y_ind = np.intersect1d(x, y, return_indices=True) |