mars.tensor.setdiff1d#

mars.tensor.setdiff1d(ar1, ar2, assume_unique=False)[源代码]#

Find the set difference of two tensors.

Return the unique values in ar1 that are not in ar2.

参数
  • ar1 (array_like) – Input tensor.

  • ar2 (array_like) – Input comparison tensor.

  • assume_unique (bool) – If True, the input tensors are both assumed to be unique, which can speed up the calculation. Default is False.

返回

setdiff1d – 1D tensor of values in ar1 that are not in ar2. The result is sorted when assume_unique=False, but otherwise only sorted if the input is sorted.

返回类型

Tensor

示例

>>> import mars.tensor as mt
>>> a = mt.array([1, 2, 3, 2, 4, 1])
>>> b = mt.array([3, 4, 5, 6])
>>> mt.setdiff1d(a, b).execute()
array([1, 2])