{ } Raw JSON

bundles / scipy 1.18.0 / scipy / _external / array_api_extra / _delegation / setdiff1d

function

scipy._external.array_api_extra._delegation:setdiff1d

source: /scipy/_external/array_api_extra/_delegation.py:715

Signature

def setdiff1d(x1: Array | complex, x2: Array | complex, /, assume_unique: bool = False, xp: ModuleType | None = None) → Array

Summary

Find the set difference of two arrays.

Extended Summary

Return the unique values in x1 that are not in x2.

Parameters

x1 : array | int | float | complex | bool

Input array.

x2 : array

Input comparison array.

assume_unique : bool

If True, the input arrays are both assumed to be unique, which can speed up the calculation. Default is False.

xp : array_namespace, optional

The standard-compatible namespace for x1 and x2. Default: infer.

Returns

: array

1D array of values in x1 that are not in x2. The result is sorted when assume_unique is False, but otherwise only sorted if the input is sorted.

Examples

import array_api_strict as xp
import array_api_extra as xpx
⚠
Traceback (most recent call last):
  File "<doctest scipy._external.array_api_extra._delegation:setdiff1d[0]>", line 1, in <module>
    import array_api_extra as xpx
ModuleNotFoundError: No module named 'array_api_extra'
x1 = xp.asarray([1, 2, 3, 2, 4, 1])
x2 = xp.asarray([3, 4, 5, 6])
xpx.setdiff1d(x1, x2, xp=xp)
⚠
Traceback (most recent call last):
  File "<doctest scipy._external.array_api_extra._delegation:setdiff1d[0]>", line 1, in <module>
    xpx.setdiff1d(x1, x2, xp=xp)
    ^^^
NameError: name 'xpx' is not defined

Aliases

  • scipy.differentiate.xpx.setdiff1d