Set difference of 1D arrays with unique elements. The output is always a masked array. See `numpy.setdiff1d` for more details. See Also -------- numpy.setdiff1d : Equivalent function for ndarrays. Examples -------- >>> x = np.ma.array([1, 2, 3, 4], mask=[0, 1,
(ar1, ar2, assume_unique=False)
| 1366 | |
| 1367 | |
| 1368 | def setdiff1d(ar1, ar2, assume_unique=False): |
| 1369 | """ |
| 1370 | Set difference of 1D arrays with unique elements. |
| 1371 | |
| 1372 | The output is always a masked array. See `numpy.setdiff1d` for more |
| 1373 | details. |
| 1374 | |
| 1375 | See Also |
| 1376 | -------- |
| 1377 | numpy.setdiff1d : Equivalent function for ndarrays. |
| 1378 | |
| 1379 | Examples |
| 1380 | -------- |
| 1381 | >>> x = np.ma.array([1, 2, 3, 4], mask=[0, 1, 0, 1]) |
| 1382 | >>> np.ma.setdiff1d(x, [1, 2]) |
| 1383 | masked_array(data=[3, --], |
| 1384 | mask=[False, True], |
| 1385 | fill_value=999999) |
| 1386 | |
| 1387 | """ |
| 1388 | if assume_unique: |
| 1389 | ar1 = ma.asarray(ar1).ravel() |
| 1390 | else: |
| 1391 | ar1 = unique(ar1) |
| 1392 | ar2 = unique(ar2) |
| 1393 | return ar1[in1d(ar1, ar2, assume_unique=True, invert=True)] |
| 1394 | |
| 1395 | |
| 1396 | ############################################################################### |