Skip to content

Commit fe99300

Browse files
committed
DOC: setdiff1d: add docs
1 parent 0b4135d commit fe99300

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

docs/api-reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
create_diagonal
1212
expand_dims
1313
kron
14+
setdiff1d
1415
sinc
1516
```

src/array_api_extra/_funcs.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,40 @@ def kron(a: Array, b: Array, /, *, xp: ModuleType) -> Array:
412412
def setdiff1d(
413413
x1: Array, x2: Array, /, *, assume_unique: bool = False, xp: ModuleType
414414
) -> Array:
415-
"""Find the set difference of two arrays.
415+
"""
416+
Find the set difference of two arrays.
416417
417418
Return the unique values in `x1` that are not in `x2`.
419+
420+
Parameters
421+
----------
422+
x1 : array
423+
Input array.
424+
x2 : array
425+
Input comparison array.
426+
assume_unique : bool
427+
If ``True``, the input arrays are both assumed to be unique, which
428+
can speed up the calculation. Default is ``False``.
429+
xp : array_namespace
430+
The standard-compatible namespace for `x1` and `x2`.
431+
432+
Returns
433+
-------
434+
res : array
435+
1D array of values in `x1` that are not in `x2`. The result
436+
is sorted when `assume_unique` is ``False``, but otherwise only sorted
437+
if the input is sorted.
438+
439+
Examples
440+
--------
441+
>>> import array_api_strict as xp
442+
>>> import array_api_extra as xpx
443+
444+
>>> x1 = xp.asarray([1, 2, 3, 2, 4, 1])
445+
>>> x2 = xp.asarray([3, 4, 5, 6])
446+
>>> xpx.setdiff1d(x1, x2, xp=xp)
447+
Array([1, 2], dtype=array_api_strict.int64)
448+
418449
"""
419450

420451
if assume_unique:

0 commit comments

Comments
 (0)