array_namespace

earthkit.utils.array.array_namespace(*args: Any) Any[source]

Return the array namespace of the arguments.

Parameters:

*args (tuple) – Scalar, string or array-like arguments.

Returns:

xp – The patched array namespace of the arguments. The namespace returned from array_api_compat.array_namespace(*args) is patched with extra/modified methods. When only a scalar is passed, the numpy namespace is returned.

Return type:

module

Notes

The array namespace is extended with the following methods when necessary:
  • polyval: evaluate a polynomial (available in numpy)

  • percentile: compute the n-th percentile of the data along the specified axis (available in numpy)

  • histogram2d: compute a 2D histogram (available in numpy)

Some other methods may be reimplemented for a given namespace to ensure correct behaviour. E.g. sign() for torch.