MCPcopy Index your code
hub / github.com/numpy/numpy / setdiff1d

Function setdiff1d

numpy/ma/extras.py:1487–1513  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1485
1486
1487def 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###############################################################################

Callers 2

test_setdiff1dMethod · 0.90

Calls 3

in1dFunction · 0.85
uniqueFunction · 0.70
ravelMethod · 0.45

Tested by 2

test_setdiff1dMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…