brainunit.assert_quantity#
- brainunit.assert_quantity(q, mantissa, unit=None)#
Assert that a Quantity has a certain mantissa and unit.
When unit is
Nonethe function checks that q is unitless and that its numeric value matches mantissa. When unit is given the function additionally checks that the dimensions agree and that the value expressed in unit matches mantissa.- Parameters:
- Raises:
AssertionError – If the value or the unit does not match.
Examples
>>> import saiunit as u >>> u.assert_quantity(u.Quantity(1, u.mV), 1, u.mV)