MCPcopy Create free account
hub / github.com/numpy/numpy / setdiff1d

Function setdiff1d

numpy/ma/extras.py:1368–1393  ·  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 -------- >>> x = np.ma.array([1, 2, 3, 4], mask=[0, 1,

(ar1, ar2, assume_unique=False)

Source from the content-addressed store, hash-verified

1366
1367
1368def 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###############################################################################

Callers 2

test_setdiff1dMethod · 0.90

Calls 3

uniqueFunction · 0.70
in1dFunction · 0.70
ravelMethod · 0.45

Tested by 2

test_setdiff1dMethod · 0.72