saiunit.array_with_unit

saiunit.array_with_unit#

saiunit.array_with_unit(mantissa, unit, dtype=None)[source]#

Create a new Quantity with the given unit.

Parameters:
  • mantissa (float or array-like) – The numeric value of the quantity.

  • unit (saiunit.Unit) – The physical unit to attach.

  • dtype (str | type[Any] | dtype | SupportsDType | None) – The data type of the underlying array.

Returns:

array – The new Quantity object.

Return type:

saiunit.Quantity

Raises:

TypeError – If unit is not a Unit instance.

Examples

>>> import saiunit as u
>>> u.array_with_unit(5.0, u.volt)
5. * volt
>>> u.array_with_unit(0.001, u.volt)
1. * mvolt