sequince.array_api#

Functions#

enable_scipy_array_api()

Enable SciPy Array API support; normally done during package import.

namespace(*arrays)

Return the array API namespace associated with the provided arrays.

determine_backend_name([x, xp])

Determine the backend name from an array or array API module.

resolve_dtype(dtype, xp)

Resolve a dtype-like value for an array API namespace.

asarray(array, *[, xp, dtype, like])

Convert an array while preserving the requested namespace and device.

copy(array, *[, xp])

Copy an array without changing its namespace or device.

to_numpy(array, *[, dtype, copy])

Detach an array, move it to CPU, and convert it to NumPy.

logsumexp(array, *[, axis, xp])

Module Contents#

sequince.array_api.enable_scipy_array_api()[source]#

Enable SciPy Array API support; normally done during package import.

Return type:

None

sequince.array_api.namespace(*arrays)[source]#

Return the array API namespace associated with the provided arrays.

Parameters:

arrays (Any)

sequince.array_api.determine_backend_name(x=None, xp=None)[source]#

Determine the backend name from an array or array API module.

Parameters:
  • x (Array or None) – The array to infer the backend from. If None, xp must be provided.

  • xp (Any or None) – The array API module to infer the backend from. If None, x must be provided.

Returns:

The name of the backend. If the backend cannot be determined, returns “unknown”.

Return type:

str

sequince.array_api.resolve_dtype(dtype, xp)[source]#

Resolve a dtype-like value for an array API namespace.

Parameters:
  • dtype (Any | str | None)

  • xp (Any)

Return type:

Any | None

sequince.array_api.asarray(array, *, xp=None, dtype=None, like=None)[source]#

Convert an array while preserving the requested namespace and device.

Parameters:
  • array (Any)

  • xp (Any | None)

  • dtype (Any | str | None)

  • like (Any | None)

sequince.array_api.copy(array, *, xp=None)[source]#

Copy an array without changing its namespace or device.

For JAX and PyTorch arrays, this will create a new array on the same device and preserves gradient tracking.

Parameters:
  • array (Any)

  • xp (Any | None)

sequince.array_api.to_numpy(array, *, dtype=None, copy=None)[source]#

Detach an array, move it to CPU, and convert it to NumPy.

Parameters:
  • array (Any)

  • dtype (Any | None)

  • copy (bool | None)

Return type:

numpy.ndarray

sequince.array_api.logsumexp(array, *, axis=None, xp=None)[source]#
Parameters:
  • array (Any)

  • axis (int | tuple[int, ...] | None)

  • xp (Any | None)