api

Utility functions to use Python Array API compatible libraries.

Copied from Scipy

For the context about the Array API see: https://data-apis.org/array-api/latest/purpose_and_scope.html

The SciPy use case of the Array API is described on the following page: https://data-apis.org/array-api/latest/use_cases.html#use-case-scipy

array_namespace(*arrays)

Get the array API compatible namespace for the arrays xs.

get_xp_devices(xp)

Returns a list of available devices for the given namespace.

intersect1d(*arrays[, assume_unique, xp])

SciPy-specific replacement for np.intersect1d with assume_unique and

is_complex(x, xp)

Check if an array has a complex floating-point data type.

scipy_namespace_for(xp)

Return the scipy-like namespace of a non-NumPy backend

split(array, indices_or_sections[, axis, xp])

SciPy-specific replacement for np.split with axis and xp.

xp_assert_equal(actual, desired, *[, ...])

Assert that two arrays are equal.

xp_assert_less(actual, desired, *[, ...])

Assert that all elements of an array are strictly less than another

xp_broadcast_promote(*args[, ...])

Broadcast arrays and promote to a common data type.

xp_copy(x, *[, xp])

Copies an array.

xp_copysign(x1, x2, /, *[, xp])

Copy the sign of x2 to the magnitude of x1.

xp_float_to_complex(arr[, xp])

Convert a floating-point array to a complex array.

xp_moveaxis_to_end(x, source, /, *[, xp])

Move an axis to the end of the array.

xp_ravel(x, /, *[, xp])

Return a flattened array.

xp_real(x, /, *[, xp])

Return the real part of a complex array or the array itself if it's

xp_sign(x, /, *[, xp])

Return the sign of each element in the input array.

xp_take_along_axis(arr, indices, /, *[, ...])

Take values from an array along an axis at the indices specified.

xp_vector_norm(x, /, *[, axis, keepdims, ...])

Compute the vector norm of an array.