attach_unit#
- tollan.utils.np.attach_unit(arr: npt.ArrayLike | np.ma.MaskedArray, unit: UnitT | None) npt.ArrayLike | np.ma.MaskedArray | u.Quantity[source]#
Attach a unit to an array if unit is not None.
- Parameters:
arr (ArrayLike | MaskedArray) – Array to attach unit to
unit (UnitT | None) – Astropy unit to attach (or None for no-op)
- Returns:
Array with unit attached (or original if unit is None)
- Return type:
ArrayLike | MaskedArray | Quantity