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 -------- >>> import numpy as np >>> x = np.ma.arra
(ar1, ar2, assume_unique=False)
| 1485 | |
| 1486 | |
| 1487 | def setdiff1d(ar1, ar2, assume_unique=False): |
| 1488 | """ |
| 1489 | Set difference of 1D arrays with unique elements. |
| 1490 | |
| 1491 | The output is always a masked array. See `numpy.setdiff1d` for more |
| 1492 | details. |
| 1493 | |
| 1494 | See Also |
| 1495 | -------- |
| 1496 | numpy.setdiff1d : Equivalent function for ndarrays. |
| 1497 | |
| 1498 | Examples |
| 1499 | -------- |
| 1500 | >>> import numpy as np |
| 1501 | >>> x = np.ma.array([1, 2, 3, 4], mask=[0, 1, 0, 1]) |
| 1502 | >>> np.ma.setdiff1d(x, [1, 2]) |
| 1503 | masked_array(data=[3, --], |
| 1504 | mask=[False, True], |
| 1505 | fill_value=999999) |
| 1506 | |
| 1507 | """ |
| 1508 | if assume_unique: |
| 1509 | ar1 = ma.asarray(ar1).ravel() |
| 1510 | else: |
| 1511 | ar1 = unique(ar1) |
| 1512 | ar2 = unique(ar2) |
| 1513 | return ar1[in1d(ar1, ar2, assume_unique=True, invert=True)] |
| 1514 | |
| 1515 | |
| 1516 | ############################################################################### |
searching dependent graphs…