enp#

[[Source]]

from etils import enp

Numpy API.

When possible, utils are meant to work with both numpy and jax.numpy.

All symbols#

Module#

enp

Numpy API.

enp.compat

Compat utils between TF/Torch/Numpy/Jax.

enp.dtypes

Dtype utils.

enp.linalg

linalg compat module for interoperability between tf, jax, numpy.

enp.typing

Typing utils.

Class#

enp.ArraySpec

Structure containing shape/dtype.

enp.NpModule

Special type indicating an unconstrained type.

enp.dtypes.AnyDType

DType which can represent any dtype.

enp.dtypes.AnyFloat

Generic float dtype (float32, float64, bfloat16,…).

enp.dtypes.AnyInt

Generic int dtype (int32, int64, uint8,…).

enp.dtypes.Casting

Casting mode when converting to array.

enp.dtypes.DType

DType wrapper.

enp.dtypes.NpDType

Raw numpy dtype.

enp.typing.Array

enp.typing.ArrayAliasMeta

Metaclass to create array aliases.

enp.typing.BoolArray

enp.typing.FloatArray

enp.typing.IntArray

enp.typing.PRNGKey

enp.typing.StrArray

enp.typing.bool_

enp.typing.complex128

enp.typing.complex64

enp.typing.f16

enp.typing.f32

enp.typing.f64

enp.typing.i16

enp.typing.i32

enp.typing.i64

enp.typing.i8

enp.typing.ui16

enp.typing.ui32

enp.typing.ui64

enp.typing.ui8

Function#

enp.angle_between

Compute angle between 2 vectors, unsigned.

enp.batch_dot

Dot product on the last dimension, with broadcasting support.

enp.check_and_normalize_arrays

Check and normalize arrays.

enp.compat.astype

x.astype(dtype).

enp.compat.concat

xnp.concatenate(x, axis=axis).

enp.compat.det

Like np.linalg.det but auto-support jnp, tnp, np.

enp.compat.dtype_np_to_torch

Returns the torch dtype for the given numpy dtype.

enp.compat.dtype_torch_to_np

Returns the numpy dtype for the given torch dtype.

enp.compat.expand_dims

xnp.expand_dims(x, axis=axis).

enp.compat.inv

Like np.linalg.inv but auto-support jnp, tnp, np.

enp.compat.is_array_xnp

isinstance(x, xnp.Array).

enp.compat.norm

Like np.linalg.norm but auto-support jnp, tnp, np.

enp.compat.round

x.round() for jnp, tnp, np, otrch.

enp.get_np_module

Returns the numpy module associated with the given array.

enp.interp

Linearly scale the given value by the given range.

enp.is_array

Returns True if array is np or jnp array.

enp.is_array_str

Returns True if the given array is a str array.

enp.is_dtype_str

Returns True if the dtype is str.

enp.linalg.normalize

Normalize the vector to the unit norm.

enp.normalize_bytes2str

Normalize bytes array to str (UTF-8).

enp.project_onto_plane

Project u onto the plane n (orthogonal vector).

enp.project_onto_vector

Project u onto v.

Attribute#

enp.compat.lazy

enp.lazy

enp.linalg.lazy

enp.tau

Mirror math.tau (PEP 628). See https://tauday.com/

Typing#

enp.typing.ArrayLike

ArrayLike indicates that any np.array input is also supported. For example: `A…