ensure_unit#
- tollan.utils.np.ensure_unit(arr: npt.ArrayLike | u.Quantity | None, unit: u.Unit) u.Quantity | None[source]#
Ensure data has the given unit (returns None if arr is None).
- Parameters:
arr (ArrayLike | Quantity | None) – Input array (with or without units)
unit (Unit) – Target unit to apply
- Returns:
Array with specified unit, or None if input is None
- Return type:
Quantity | None