empty_like#
- class saiunit.math.empty_like(prototype, dtype=None, shape=None, unit=Unit('1'))#
Return a new uninitialized quantity or array with the same shape and type as a given array.
- Parameters:
prototype (
Union[saiunit.Quantity,Array,ndarray,number,bool]) – The shape and data-type ofprototypedefine these same attributes of the returned array.dtype (
Union[str,type[Any],dtype,SupportsDType,None]) – Overrides the data type of the result.shape (
Union[int,Sequence[int],None]) – Overrides the shape of the result. If not given,prototype.shapeis used.unit (saiunit.Unit) – Unit of the returned
Quantity.
- Returns:
out – Array of uninitialized (arbitrary) data with the same shape and type as
prototype.- Return type:
Union[saiunit.Quantity,Array]
Examples
>>> import saiunit as u >>> import jax.numpy as jnp >>> result = u.math.empty_like(jnp.array([1.0, 2.0, 3.0])) >>> result.shape (3,)