Returns the unique elements common to both arrays. Masked values are considered equal one to the other. The output is always a masked array. See `numpy.intersect1d` for more details. See Also -------- numpy.intersect1d : Equivalent function for ndarrays. Examples
(ar1, ar2, assume_unique=False)
| 1228 | |
| 1229 | |
| 1230 | def intersect1d(ar1, ar2, assume_unique=False): |
| 1231 | """ |
| 1232 | Returns the unique elements common to both arrays. |
| 1233 | |
| 1234 | Masked values are considered equal one to the other. |
| 1235 | The output is always a masked array. |
| 1236 | |
| 1237 | See `numpy.intersect1d` for more details. |
| 1238 | |
| 1239 | See Also |
| 1240 | -------- |
| 1241 | numpy.intersect1d : Equivalent function for ndarrays. |
| 1242 | |
| 1243 | Examples |
| 1244 | -------- |
| 1245 | >>> x = np.ma.array([1, 3, 3, 3], mask=[0, 0, 0, 1]) |
| 1246 | >>> y = np.ma.array([3, 1, 1, 1], mask=[0, 0, 0, 1]) |
| 1247 | >>> np.ma.intersect1d(x, y) |
| 1248 | masked_array(data=[1, 3, --], |
| 1249 | mask=[False, False, True], |
| 1250 | fill_value=999999) |
| 1251 | |
| 1252 | """ |
| 1253 | if assume_unique: |
| 1254 | aux = ma.concatenate((ar1, ar2)) |
| 1255 | else: |
| 1256 | # Might be faster than unique( intersect1d( ar1, ar2 ) )? |
| 1257 | aux = ma.concatenate((unique(ar1), unique(ar2))) |
| 1258 | aux.sort() |
| 1259 | return aux[:-1][aux[1:] == aux[:-1]] |
| 1260 | |
| 1261 | |
| 1262 | def setxor1d(ar1, ar2, assume_unique=False): |