mars.tensor.
union1d
Find the union of two tensors.
Return the unique, sorted tensor of values that are in either of the two input tensors.
ar1 (array_like) – Input tensors. They are flattened if they are not already 1D.
ar2 (array_like) – Input tensors. They are flattened if they are not already 1D.
union1d – Unique, sorted union of the input tensors.
Tensor
Examples
>>> import mars.tensor as mt
>>> mt.union1d([-1, 0, 1], [-2, 0, 2]).execute() array([-2, -1, 0, 1, 2])
To find the union of more than two arrays, use functools.reduce:
>>> from functools import reduce >>> reduce(mt.union1d, ([1, 3, 4, 3], [3, 1, 2, 1], [6, 3, 4, 2])).execute() array([1, 2, 3, 4, 6])