with_power

justunits.AUnit.with_power(self, power: Union[int, float]) justunits.AUnit

Returns a unit based on this unit’s base unit with the requested power.

Parameters

power – Power the new unit should carry.

Returns

AUnit

Examples

>>> import justunits
>>> from justunits import SiUnits, SiPrefixes
>>> capture_time = SiUnits.second.with_prefix(SiPrefixes.nano)
>>> capture_time
AUnit(ns 'nanosecond' time, 1e-09s)
>>> frames_per_second = capture_time.with_power(-1)
>>> frames_per_second
AUnit(ns 'nanosecond' time, 1e-09s; power=-1)
>>> justunits.to_string(frames_per_second)
'ns'