diff options
author | Robert Cimrman <cimrman3@ntc.zcu.cz> | 2007-12-20 10:30:45 +0000 |
---|---|---|
committer | Robert Cimrman <cimrman3@ntc.zcu.cz> | 2007-12-20 10:30:45 +0000 |
commit | 6509e216aff93a821829cbc6a6d91bb00a4f3a23 (patch) | |
tree | b23333194046df8e44c50f0fd2f43b11d827644f /numpy/lib/arraysetops.py | |
parent | 6ede27f974dc49705dfca697a9e9542537f14a2d (diff) | |
download | numpy-6509e216aff93a821829cbc6a6d91bb00a4f3a23.tar.gz |
fixed setmember1d for string arrays
Diffstat (limited to 'numpy/lib/arraysetops.py')
-rw-r--r-- | numpy/lib/arraysetops.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py index 6693fa81c..1d99f7a97 100644 --- a/numpy/lib/arraysetops.py +++ b/numpy/lib/arraysetops.py @@ -201,9 +201,13 @@ def setmember1d( ar1, ar2 ): numpy.lib.arraysetops has a number of other functions for performing set operations on arrays. """ - zlike = nm.zeros_like + ar1 = nm.asarray( ar1 ) + ar2 = nm.asarray( ar2 ) ar = nm.concatenate( (ar1, ar2 ) ) - tt = nm.concatenate( (zlike( ar1 ), zlike( ar2 ) + 1) ) + b1 = nm.zeros( ar1.shape, dtype = nm.int8 ) + b2 = nm.ones( ar2.shape, dtype = nm.int8 ) + tt = nm.concatenate( (b1, b2) ) + # We need this to be a stable sort, so always use 'mergesort' here. The # values from the first array should always come before the values from the # second array. @@ -212,7 +216,6 @@ def setmember1d( ar1, ar2 ): aux2 = tt[perm] # flag = ediff1d( aux, 1 ) == 0 flag = nm.concatenate( (aux[1:] == aux[:-1], [False] ) ) - ii = nm.where( flag * aux2 )[0] aux = perm[ii+1] perm[ii+1] = perm[ii] |