units package¶
Package for physical quantity modules and classes.
- class units.Acceleration(value: float, distance_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None)[source]¶
The rate of change of the velocity of an object with respect to time.
- __abs__() Acceleration [source]¶
Return the absolute version of the acceleration.
- __add__(other: Acceleration) Acceleration [source]¶
Return the sum of two accelerations.
- __divmod__(other: Acceleration) tuple[float, float] [source]¶
Return the quotient & remainder of the ratio between the accelerations.
- __floordiv__(other: Acceleration) float [source]¶
Return the floored ratio between the accelerations.
- __ge__(other: Acceleration) bool [source]¶
Return whether the acceleration is greater than or equal to the other.
- __gt__(other: Acceleration) bool [source]¶
Return whether the acceleration is greater than the other.
- __init__(value: float, distance_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None) None [source]¶
Initialise a new acceleration.
If a second time unit is not provided, the first time unit will be reused.
- __le__(other: Acceleration) bool [source]¶
Return whether the acceleration is less than or equal to the other.
- __lt__(other: Acceleration) bool [source]¶
Return whether the acceleration is less than the other.
- __mod__(other: Acceleration) float [source]¶
Return the remainder of the ratio between the acceleration.
- __mul__(value: float) Acceleration [source]¶
Return an acceleration scaled by the value.
- __neg__() Acceleration [source]¶
Return the inverse of the acceleration.
- __rmul__(value: float) Acceleration [source]¶
Return an acceleration scaled by the value.
- __sub__(other: Acceleration) Acceleration [source]¶
Return the difference of two accelerations.
- __truediv__(other: float | Acceleration) Acceleration | float [source]¶
Return a scaled acceleration or the ratio between the accelerations.
The behaviour depends upon the type of the argument.
If the argument is a
float
, return an acceleration scaled by the inverse of the valueIf the argument is a
Acceleration
, return the ratio between the two accelerations
- class units.Angle(value: float, unit: Unit)[source]¶
The opening between two lines in the same plane that meet at a point.
Angle always in range [0, 2*pi) radians.
- __add__(delta: AngleDelta) Angle [source]¶
Return the sum of the angle and the difference.
- __init__(value: float, unit: Unit) None [source]¶
Initialise a new angle.
Values outside of the range range [0, 2*pi) radians will be mapped into it.
Range
INITIALIZATION
EQUIVALENT TO
Within
Angle(185, Unit.DEGREE)
Angle(185, Unit.DEGREE)
Below
Angle(-3*math.pi, Unit.RADIAN)
Angle(math.pi, Unit.RADIAN)
Above
Angle(4, Unit.REVOLUTION)
Angle(0, Unit.REVOLUTION)
- __radd__(delta: AngleDelta) Angle [source]¶
Return the sum of the angle and the difference.
- __sub__(other: Angle | AngleDelta) AngleDelta | Angle [source]¶
Return the delta between angles or the angle less the delta.
The behaviour depends upon the type of the argument.
If the argument is an angle, return the difference between the two angles.
If the argument is an angle delta, return the angle less the difference.
- class units.AngleDelta(value: float, unit: Unit)[source]¶
The difference between two angles.
Angle difference always in range [-pi, pi) radians.
- __add__(other: AngleDelta) AngleDelta [source]¶
Return the sum of the angle differences.
- __init__(value: float, unit: Unit) None [source]¶
Initialise a new angle difference.
Values outside the range [-pi, pi) radians will be mapped into it.
Range
INITIALIZATION
EQUIVALENT TO
Within
AngleDelta(-40, Unit.DEGREE)
AngleDelta(-40, Unit.DEGREE)
Below
AngleDelta(-3*pi, Unit.RADIAN)
AngleDelta(pi, Unit.RADIAN)
Above
AngleDelta(3.75, Unit.REVOLUTION)
AngleDelta(-0.25, Unit.REVOLUTION)
- __neg__() AngleDelta [source]¶
Return the inverse of the angle difference.
- __sub__(delta: AngleDelta) AngleDelta [source]¶
Return the difference between the angle differences.
- units.AngleUnit¶
alias of
Unit
- units.AngularAcceleration¶
alias of
Acceleration
- units.AngularDisplacement¶
alias of
Displacement
- units.AngularJerk¶
alias of
Jerk
- units.AngularVelocity¶
alias of
Velocity
- class units.Area(value: float, unit: Unit)[source]¶
The measure of a two-dimensional space.
- __add__(delta: AreaDelta) Area [source]¶
Return the sum of the area and the difference.
- Raises:
NegativeAreaValueError – The sum of the area and the difference was less than 0m^2.
- __init__(value: float, unit: Unit) None [source]¶
Initialise a new area.
- Raises:
NegativeAreaValueError – The negative value produced an area less than 0m^2.
- __sub__(other: Area | AreaDelta) AreaDelta | Area [source]¶
Return the delta between two areas or the area less the delta.
The behaviour depends upon the type of the argument.
If the argument is a
Area
, return the difference between the two areas.If the argument is a
AreaDelta
, return the area less the difference.
- Raises:
NegativeAreaValueError – The area minus the difference was less than 0m^2. Error can only be raised when other is an
AreaDelta
.
- class units.AreaDelta(value: float, unit: Unit)[source]¶
The difference between two areas.
- __divmod__(other: AreaDelta) tuple[float, float] [source]¶
Return the quotient & remainder of the ratio between the area deltas.
- __floordiv__(other: AreaDelta) float [source]¶
Return the floored ratio between the area differences.
- __ge__(other: AreaDelta) bool [source]¶
Return whether the area delta is greater than or equal to the other.
- __gt__(other: AreaDelta) bool [source]¶
Return whether the area difference is greater than the other.
- __le__(other: AreaDelta) bool [source]¶
Return whether the area delta is less than or equal to the other.
- __mod__(other: AreaDelta) float [source]¶
Return the remainder of the ratio between the area differences.
- __truediv__(other: float | AreaDelta) AreaDelta | float [source]¶
Return a scaled area difference or the ratio between the differences.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a area difference scaled by the inverse of the valueIf the argument is a
AreaDelta
, return the ratio between the two differences
- units.AreaUnit¶
alias of
Unit
- exception units.BelowAbsoluteZeroError(value: float, unit: Unit, *args: tuple[Any, ...], **kwargs: dict[str, Any])[source]¶
Raised when the temperature would be less than absolute zero.
The minimum temperature that can exist is absolute zero (0 K), so a temperature less than this is impossible.
- __init__(value: float, unit: Unit, *args: tuple[Any, ...], **kwargs: dict[str, Any]) None [source]¶
Initialise a new below-absolute-zero exception.
- property unit: Unit¶
The temperature unit that caused the error.
- property value: float¶
The temperature value that caused the error.
- class units.Current(value: float, unit: Unit)[source]¶
The flow of charged particles through an electrical conductor.
- __divmod__(other: Current) tuple[float, float] [source]¶
Return the quotient & remainder of the ratio between the currents.
- __ge__(other: Current) bool [source]¶
Return whether the current is greater than or equal to the other.
- __le__(other: Current) bool [source]¶
Return whether the current is less than or equal to the other.
- __truediv__(other: float | Current) Current | float [source]¶
Return a scaled current or the ratio between the currents.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a current scaled by the inverse of the valueIf the argument is a
Current
, return the ratio between the two currents
- units.CurrentUnit¶
alias of
Unit
- class units.Displacement(value: float, unit: Unit)[source]¶
The difference between the final and initial position of a trajectory.
- __abs__() Displacement [source]¶
Return the absolute version of the displacement.
- __add__(other: Displacement) Displacement [source]¶
Return the sum of the displacements.
- __divmod__(other: Displacement) tuple[float, float] [source]¶
Return the quotient & remainder of the ratio between the displacements.
- __floordiv__(other: Displacement) float [source]¶
Return the floored ratio between the displacements.
- __ge__(other: Displacement) bool [source]¶
Return whether the displacement is greater than or equal to the other.
- __gt__(other: Displacement) bool [source]¶
Return whether the displacement is greater than the other.
- __le__(other: Displacement) bool [source]¶
Return whether the displacement is less than or equal to the other.
- __lt__(other: Displacement) bool [source]¶
Return whether the displacement is less than the other.
- __mod__(other: Displacement) float [source]¶
Return the remainder of the ratio between the displacements.
- __mul__(value: float) Displacement [source]¶
Return a displacement scaled by the value.
- __neg__() Displacement [source]¶
Return the inverse of the displacement.
- __rmul__(value: float) Displacement [source]¶
Return a displacement scaled by the value.
- __sub__(delta: Displacement) Displacement [source]¶
Return the difference between the displacements.
- __truediv__(other: float | Displacement) Displacement | float [source]¶
Return a scaled displacement or the ratio between the displacements.
The behaviour depends upon the type of the argument.
If the argument is a
float
, return a displacement scaled by the inverse of the valueIf the argument is a
Displacement
, return the ratio between the two displacements
- units.DistanceUnit¶
alias of
Unit
- class units.Jerk(value: float, distance_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None, third_time_unit: Unit | None = None)[source]¶
The rate of change of the jerk of an object with respect to time.
- __divmod__(other: Jerk) tuple[float, float] [source]¶
Return the quotient & remainder of the ratio between the jerks.
- __init__(value: float, distance_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None, third_time_unit: Unit | None = None) None [source]¶
Initialise a new jerk.
If a second time unit is not provided, the first time unit will be reused. If the third time unit is not provided, the second time unit will be reused (or the first, if the second is also not provided).
- __truediv__(other: float | Jerk) Jerk | float [source]¶
Return a scaled jerk or the ratio between the jerks.
The behaviour depends upon the type of the argument.
If the argument is a
float
, return an jerk scaled by the inverse of the valueIf the argument is a
Jerk
, return the ratio between the two jerks
- as_unit(distance_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None, third_time_unit: Unit | None = None) float [source]¶
Return the jerk in the specified units.
If a second time unit is not provided, the first time unit will be reused. If the third time unit is not provided, the second time unit will be reused (or the first, if the second is also not provided).
- class units.Length(value: float, unit: Unit)[source]¶
The measure of distance.
- __add__(delta: LengthDelta) Length [source]¶
Return the sum of the length and the difference.
- Raises:
NegativeLengthValueError – The sum of the length and the difference was less than 0m.
- __ge__(other: Length) bool [source]¶
Return whether the length is greater than or equal to the other.
- __init__(value: float, unit: Unit) None [source]¶
Initialise a new length.
- Raises:
NegativeLengthValueError – The negative value produced a length less than 0m.
- __radd__(delta: LengthDelta) Length [source]¶
Return the sum of the length and the difference.
- __sub__(other: Length | LengthDelta) LengthDelta | Length [source]¶
Return the delta between lengths or the length less the delta.
The behaviour depends upon the type of the argument.
If the argument is a
Length
, return the difference between the two lengths.If the argument is a
LengthDelta
, return the length less the difference.
- Raises:
NegativeLengthValueError – The length minus the difference was less than 0m. Error can only be raised when other is a
LengthDelta
.
- class units.LengthDelta(value: float, unit: Unit)[source]¶
The difference between two lengths.
- __abs__() LengthDelta [source]¶
Return the absolute version of the length difference.
- __add__(other: LengthDelta) LengthDelta [source]¶
Return the sum of the length differences.
- __divmod__(other: LengthDelta) tuple[float, float] [source]¶
Return the quotient & remainder of the ratio between the length deltas.
- __floordiv__(other: LengthDelta) float [source]¶
Return the floored ratio between the length differences.
- __ge__(other: LengthDelta) bool [source]¶
Return whether the length delta is greater than or equal to the other.
- __gt__(other: LengthDelta) bool [source]¶
Return whether the length difference is greater than the other.
- __le__(other: LengthDelta) bool [source]¶
Return whether the length difference is less than or equal to the other.
- __lt__(other: LengthDelta) bool [source]¶
Return whether the length difference is less than the other.
- __mod__(other: LengthDelta) float [source]¶
Return the remainder of the ratio between the length differences.
- __mul__(value: float) LengthDelta [source]¶
Return a length difference scaled by the value.
- __neg__() LengthDelta [source]¶
Return the inverse of the length difference.
- __rmul__(value: float) LengthDelta [source]¶
Return a length difference scaled by the value.
- __sub__(delta: LengthDelta) LengthDelta [source]¶
Return the difference between the length differences.
- __truediv__(other: float | LengthDelta) LengthDelta | float [source]¶
Return a scaled length difference or the ratio between the differences.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a length difference scaled by the inverse of the valueIf the argument is a
LengthDelta
, return the ratio between the two differences
- class units.Mass(value: float, unit: Unit)[source]¶
The force applied per unit area over which that force is distributed.
- __add__(delta: MassDelta) Mass [source]¶
Return the sum of the mass and the difference.
- Raises:
NegativeMassValueError – The sum of the mass and the difference was less than 0kg.
- __init__(value: float, unit: Unit) None [source]¶
Initialise a new mass.
- Raises:
NegativeMassValueError – The negative value produced a mass less than 0kg.
- __sub__(other: Mass | MassDelta) MassDelta | Mass [source]¶
Return the delta between mass or the mass less the delta.
The behaviour depends upon the type of the argument.
If the argument is a
Mass
, return the difference between the two masses.If the argument is a
MassDelta
, return the mass less the difference.
- Raises:
NegativeMassValueError – The mass minus the difference was less than 0kg. Only possible when other is a MassDelta.
- class units.MassDelta(value: float, unit: Unit)[source]¶
The difference between two masses.
- __divmod__(other: MassDelta) tuple[float, float] [source]¶
Return the quotient & remainder of the ratio between the mass deltas.
- __floordiv__(other: MassDelta) float [source]¶
Return the floored ratio between the mass differences.
- __ge__(other: MassDelta) bool [source]¶
Return whether the mass delta is greater than or equal to the other.
- __gt__(other: MassDelta) bool [source]¶
Return whether the mass difference is greater than the other.
- __le__(other: MassDelta) bool [source]¶
Return whether the mass delta is less than or equal to the other.
- __mod__(other: MassDelta) float [source]¶
Return the remainder of the ratio between the mass differences.
- __truediv__(other: float | MassDelta) MassDelta | float [source]¶
Return a scaled mass difference or the ratio between the differences.
The behaviour depends upon the type of the argument.
If the argument is a
float
, return a mass difference scaled by the inverse of the valueIf the argument is a
MassDelta
, return the ratio between the two differences
- class units.MassFlowRate(value: float, mass_unit: Unit, time_unit: Unit)[source]¶
The mass of a gas or liquid that flows in a certain amount of time.
- __abs__() MassFlowRate [source]¶
Return the absolute version of the flow rate.
- __add__(other: MassFlowRate) MassFlowRate [source]¶
Return the sum of two flow rates.
- __divmod__(other: MassFlowRate) tuple[float, float] [source]¶
Return the quotient & remainder of the ratio between the flow rates.
- __floordiv__(other: MassFlowRate) float [source]¶
Return the floored ratio between the flow rates.
- __ge__(other: MassFlowRate) bool [source]¶
Return whether the flow rate is greater than or equal to the other.
- __gt__(other: MassFlowRate) bool [source]¶
Return whether the flow rate is greater than the other.
- __le__(other: MassFlowRate) bool [source]¶
Return whether the flow rate is less than or equal to the other.
- __lt__(other: MassFlowRate) bool [source]¶
Return whether the flow rate is less than the other.
- __mod__(other: MassFlowRate) float [source]¶
Return the remainder of the ratio between the flow rate.
- __mul__(value: float) MassFlowRate [source]¶
Return a flow rate scaled by the value.
- __neg__() MassFlowRate [source]¶
Return the inverse of the flow rate.
- __rmul__(value: float) MassFlowRate [source]¶
Return a flow rate scaled by the value.
- __sub__(other: MassFlowRate) MassFlowRate [source]¶
Return the difference of two flow rates.
- __truediv__(other: float | MassFlowRate) MassFlowRate | float [source]¶
Return a scaled flow rate or the ratio between the flow rates.
The behaviour depends upon the type of the argument.
If the argument is a
float
, return a flow rate scaled by the inverse of the valueIf the argument is a
MassFlowRate
, return the ratio between the two flow rates
- units.MassUnit¶
alias of
Unit
- exception units.NegativeAreaValueError(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any])[source]¶
Raised when the area value is negative.
The minimum area that can exist is 0 m^2, so an area with a negative value, regardless of the unit, is impossible.
- __init__(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any]) None [source]¶
Initialise a new negative-area exception.
- property value: float¶
The area value that caused the error.
- exception units.NegativeLengthValueError(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any])[source]¶
Raised when the length value is negative.
The minimum length that can exist is 0m, so a length with a negative value, regardless of the unit, is impossible.
- __init__(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any]) None [source]¶
Initialise a new negative-length exception.
- property value: float¶
The length value that caused the error.
- exception units.NegativeMassValueError(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any])[source]¶
Raised when the mass value is negative.
The minimum mass that can exist is 0 kg, so a mass with a negative value, regardless of the unit, is impossible.
- __init__(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any]) None [source]¶
Initialise a new negative-mass exception.
- property value: float¶
The mass value that caused the error.
- exception units.NegativePressureValueError(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any])[source]¶
Raised when the pressure value is negative.
The minimum pressure that can exist is a perfect vacuum (0 Pa), so a pressure with a negative value, regardless of the unit, is impossible.
- __init__(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any]) None [source]¶
Initialise a new negative-pressure exception.
- property value: float¶
The pressure value that caused the error.
- exception units.NegativeTimeValueError(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any])[source]¶
Raised when the time value is negative.
The minimum time that can exist is 0s, so a time with a negative value, regardless of the unit, is impossible.
- __init__(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any]) None [source]¶
Initialise a new negative-time exception.
- property value: float¶
The time value that caused the error.
- exception units.NegativeVolumeValueError(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any])[source]¶
Raised when the volume value is negative.
The minimum volume that can exist is 0 m^3, so a volume with a negative value, regardless of the unit, is impossible.
- __init__(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any]) None [source]¶
Initialise a new negative-volume exception.
- property value: float¶
The volume value that caused the error.
- class units.Pressure(value: float, unit: Unit)[source]¶
The force applied per unit area over which that force is distributed.
- __add__(delta: PressureDelta) Pressure [source]¶
Return the sum of the pressure and the difference.
- Raises:
NegativePressureValueError – The sum of the pressure and the difference was less than 0Pa.
- __ge__(other: Pressure) bool [source]¶
Return whether the pressure is greater than or equal to the other.
- __init__(value: float, unit: Unit) None [source]¶
Initialise a new pressure.
- Raises:
NegativePressureValueError – The negative value produced a pressure less than 0Pa.
- __le__(other: Pressure) bool [source]¶
Return whether the pressure is less than or equal to the other.
- __radd__(delta: PressureDelta) Pressure [source]¶
Return the sum of the pressure and the difference.
- __sub__(other: Pressure | PressureDelta) PressureDelta | Pressure [source]¶
Return the delta between pressures or the pressure less the delta.
The behaviour depends upon the type of the argument.
If the argument is a
Pressure
, return the difference between the two pressures.If the argument is a
PressureDelta
, return the pressure less the difference.
- Raises:
NegativePressureValueError – The pressure minus the difference was less than 0Pa. Error can only be raised when other is a
PressureDelta
.
- class units.PressureDelta(value: float, unit: Unit)[source]¶
The difference between two pressures.
- __abs__() PressureDelta [source]¶
Return the absolute version of the pressure difference.
- __add__(other: PressureDelta) PressureDelta [source]¶
Return the sum of the pressure differences.
- __divmod__(other: PressureDelta) tuple[float, float] [source]¶
Return the quotient & remainder of the ratio between the pressure deltas.
- __floordiv__(other: PressureDelta) float [source]¶
Return the floored ratio between the pressure differences.
- __ge__(other: PressureDelta) bool [source]¶
Return whether the pressure delta is greater than or equal to the other.
- __gt__(other: PressureDelta) bool [source]¶
Return whether the pressure difference is greater than the other.
- __le__(other: PressureDelta) bool [source]¶
Return whether the pressure delta is less than or equal to the other.
- __lt__(other: PressureDelta) bool [source]¶
Return whether the pressure difference is less than the other.
- __mod__(other: PressureDelta) float [source]¶
Return the remainder of the ratio between the pressure differences.
- __mul__(value: float) PressureDelta [source]¶
Return a pressure difference scaled by the value.
- __neg__() PressureDelta [source]¶
Return the inverse of the pressure difference.
- __rmul__(value: float) PressureDelta [source]¶
Return a pressure difference scaled by the value.
- __sub__(delta: PressureDelta) PressureDelta [source]¶
Return the difference between the pressure differences.
- __truediv__(other: float | PressureDelta) PressureDelta | float [source]¶
Return a scaled pressure difference or the ratio between the differences.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a pressure difference scaled by the inverse of the valueIf the argument is a
PressureDelta
, return the ratio between the two differences
- units.PressureUnit¶
alias of
Unit
- class units.Temperature(value: float, unit: Unit)[source]¶
Quantitatively expresses the attribute of hotness or coldness.
- __add__(delta: TemperatureDelta) Temperature [source]¶
Return the sum of the temperature and the difference.
- Raises:
BelowAbsoluteZeroError – The sum of the temperature and the difference was less than absolute zero.
- __ge__(other: Temperature) bool [source]¶
Return whether the temperature is greater than or equal to the other.
- __gt__(other: Temperature) bool [source]¶
Return whether the temperature is greater than the other.
- __init__(value: float, unit: Unit) None [source]¶
Initialise a new temperature.
- Raises:
BelowAbsoluteZeroError – The value and unit produced an invalid temperature less than absolute zero.
- __le__(other: Temperature) bool [source]¶
Return whether the temperature is less than or equal to the other.
- __lt__(other: Temperature) bool [source]¶
Return whether the temperature is less than the other.
- __radd__(delta: TemperatureDelta) Temperature [source]¶
Return the sum of the temperature and the difference.
- __sub__(other: Temperature | TemperatureDelta) TemperatureDelta | Temperature [source]¶
Return the delta between temperatures or the temperature less the delta.
The behaviour depends upon the type of the argument.
If the argument is a
Temperature
, return the difference between the two temperatures.If the argument is a
TemperatureDelta
, return the temperature less the difference.
- Raises:
BelowAbsoluteZeroError – The temperature minus the difference was less than absolute zero.Error can only be raised when other is a
TemperatureDelta
.
- class units.TemperatureDelta(value: float, unit: Unit)[source]¶
The difference between two temperatures.
- __abs__() TemperatureDelta [source]¶
Return the absolute version of the temperature difference.
- __add__(other: TemperatureDelta) TemperatureDelta [source]¶
Return the sum of the temperature differences.
- __divmod__(other: TemperatureDelta) tuple[float, float] [source]¶
Return the quotient and remainder of the ratio between the temp deltas.
- __floordiv__(other: TemperatureDelta) float [source]¶
Return the floored ratio between the temperature differences.
- __ge__(other: TemperatureDelta) bool [source]¶
Return whether the temperature delta is greater than or equal to other.
- __gt__(other: TemperatureDelta) bool [source]¶
Return whether the temperature difference is greater than the other.
- __le__(other: TemperatureDelta) bool [source]¶
Return whether the temperature delta is less than or equal to the other.
- __lt__(other: TemperatureDelta) bool [source]¶
Return whether the temperature difference is less than the other.
- __mod__(other: TemperatureDelta) float [source]¶
Return the remainder of the ratio between the temperature differences.
- __mul__(value: float) TemperatureDelta [source]¶
Return a temperature difference scaled by the value.
- __neg__() TemperatureDelta [source]¶
Return the inverse of the temperature difference.
- __rmul__(value: float) TemperatureDelta [source]¶
Return a temperature difference scaled by the value.
- __sub__(delta: TemperatureDelta) TemperatureDelta [source]¶
Return the difference between the temperature differences.
- __truediv__(other: float | TemperatureDelta) TemperatureDelta | float [source]¶
Return a scaled temperature difference or the ratio between the differences.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a temperature difference scaled by the inverse of the valueIf the argument is a
TemperatureDelta
, return the ratio between the two differences
- units.TemperatureUnit¶
alias of
Unit
- class units.Time(value: float, unit: Unit)[source]¶
The measure in which events can be ordered from the past into the future.
- __add__(delta: TimeDelta) Time [source]¶
Return the sum of the time and the difference.
- Raises:
NegativeTimeValueError – The sum of the time and the difference was less than 0s.
- __init__(value: float, unit: Unit) None [source]¶
Initialise a new time.
- Raises:
NegativeTimeValueError – The negative value produced a time less than 0s.
- __sub__(other: Time | TimeDelta) TimeDelta | Time [source]¶
Return the delta between times or the time less the delta.
The behaviour depends upon the type of the argument.
If the argument is a
Time
, return the difference between the two times.If the argument is a
TimeDelta
, return the time less the difference.
- Raises:
NegativeTimeValueError – The time minus the difference was less than 0s. Error can only be raised when other is a
TimeDelta
.
- class units.TimeDelta(value: float, unit: Unit)[source]¶
The difference between two times.
- __divmod__(other: TimeDelta) tuple[float, float] [source]¶
Return the quotient & remainder of the ratio between the time deltas.
- __floordiv__(other: TimeDelta) float [source]¶
Return the floored ratio between the time differences.
- __ge__(other: TimeDelta) bool [source]¶
Return whether the time delta is greater than or equal to the other.
- __gt__(other: TimeDelta) bool [source]¶
Return whether the time difference is greater than the other.
- __le__(other: TimeDelta) bool [source]¶
Return whether the time delta is less than or equal to the other.
- __mod__(other: TimeDelta) float [source]¶
Return the remainder of the ratio between the time differences.
- __truediv__(other: float | TimeDelta) TimeDelta | float [source]¶
Return a scaled time difference or the ratio between the differences.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a time difference scaled by the inverse of the valueIf the argument is a
TimeDelta
, return the ratio between the two differences
- units.TimeUnit¶
alias of
Unit
- class units.Velocity(value: float, distance_unit: Unit, time_unit: Unit)[source]¶
The rate of change of the displacement of an object wrt time.
- __divmod__(other: Velocity) tuple[float, float] [source]¶
Return the quotient & remainder of the ratio between the velocities.
- __ge__(other: Velocity) bool [source]¶
Return whether the velocity is greater than or equal to the other.
- __init__(value: float, distance_unit: Unit, time_unit: Unit) None [source]¶
Initialise a new velocity.
- __le__(other: Velocity) bool [source]¶
Return whether the velocity is less than or equal to the other.
- __truediv__(other: float | Velocity) Velocity | float [source]¶
Return a scaled velocity or the ratio between the velocities.
The behaviour depends upon the type of the argument.
If the argument is a
float
, return a velocity scaled by the inverse of the valueIf the argument is a
Velocity
, return the ratio between the two velocities
- class units.Voltage(value: float, unit: Unit)[source]¶
The difference in electric potential between two points.
- __divmod__(other: Voltage) tuple[float, float] [source]¶
Return the quotient & remainder of the ratio between the voltages.
- __ge__(other: Voltage) bool [source]¶
Return whether the voltage is greater than or equal to the other.
- __le__(other: Voltage) bool [source]¶
Return whether the voltage is less than or equal to the other.
- __truediv__(other: float | Voltage) Voltage | float [source]¶
Return a scaled voltage or the ratio between the voltages.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a voltage scaled by the inverse of the valueIf the argument is a
Voltage
, return the ratio between the two voltages
- units.VoltageUnit¶
alias of
Unit
- class units.Volume(value: float, unit: Unit)[source]¶
The measure of a three-dimensional space.
- __add__(delta: VolumeDelta) Volume [source]¶
Return the sum of the volume and the difference.
- Raises:
NegativeVolumeValueError – The sum of the volume and the difference was less than 0m^3.
- __ge__(other: Volume) bool [source]¶
Return whether the volume is greater than or equal to the other.
- __init__(value: float, unit: Unit) None [source]¶
Initialise a new volume.
- Raises:
NegativeVolumeValueError – The negative value produced a volume less than 0m^3.
- __radd__(delta: VolumeDelta) Volume [source]¶
Return the sum of the volume and the difference.
- __sub__(other: Volume | VolumeDelta) VolumeDelta | Volume [source]¶
Return the delta between volumes or the volume less the delta.
The behaviour depends upon the type of the argument.
If the argument is a
Volume
, return the difference between the two volumes.If the argument is a
VolumeDelta
, return the volume less the difference.
- Raises:
NegativeVolumeValueError – The volume minus the difference was less than 0m^3. Error can only be raised when other is a
VolumeDelta
.
- class units.VolumeDelta(value: float, unit: Unit)[source]¶
The difference between two volumes.
- __abs__() VolumeDelta [source]¶
Return the absolute version of the volume difference.
- __add__(other: VolumeDelta) VolumeDelta [source]¶
Return the sum of the volume differences.
- __divmod__(other: VolumeDelta) tuple[float, float] [source]¶
Return the quotient & remainder of the ratio between the volume deltas.
- __floordiv__(other: VolumeDelta) float [source]¶
Return the floored ratio between the volume differences.
- __ge__(other: VolumeDelta) bool [source]¶
Return whether the volume delta is greater than or equal to the other.
- __gt__(other: VolumeDelta) bool [source]¶
Return whether the volume difference is greater than the other.
- __le__(other: VolumeDelta) bool [source]¶
Return whether the volume delta is less than or equal to the other.
- __lt__(other: VolumeDelta) bool [source]¶
Return whether the volume difference is less than the other.
- __mod__(other: VolumeDelta) float [source]¶
Return the remainder of the ratio between the volume differences.
- __mul__(value: float) VolumeDelta [source]¶
Return a volume difference scaled by the value.
- __neg__() VolumeDelta [source]¶
Return the inverse of the volume difference.
- __rmul__(value: float) VolumeDelta [source]¶
Return a volume difference scaled by the value.
- __sub__(delta: VolumeDelta) VolumeDelta [source]¶
Return the difference between the volume differences.
- __truediv__(other: float | VolumeDelta) VolumeDelta | float [source]¶
Return a scaled volume difference or the ratio between the differences.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a volume difference scaled by the inverse of the valueIf the argument is a
VolumeDelta
, return the ratio between the two differences
- units.VolumeUnit¶
alias of
Unit
- class units.VolumetricFlowRate(value: float, volume_unit: Unit, time_unit: Unit)[source]¶
The volume of a gas or liquid that flows in a certain amount of time.
- __abs__() VolumetricFlowRate [source]¶
Return the absolute version of the flow rate.
- __add__(other: VolumetricFlowRate) VolumetricFlowRate [source]¶
Return the sum of two flow rates.
- __divmod__(other: VolumetricFlowRate) tuple[float, float] [source]¶
Return the quotient & remainder of the ratio between the flow rates.
- __floordiv__(other: VolumetricFlowRate) float [source]¶
Return the floored ratio between the flow rates.
- __ge__(other: VolumetricFlowRate) bool [source]¶
Return whether the flow rate is greater than or equal to the other.
- __gt__(other: VolumetricFlowRate) bool [source]¶
Return whether the flow rate is greater than the other.
- __init__(value: float, volume_unit: Unit, time_unit: Unit) None [source]¶
Initialise a new flow rate.
- __le__(other: VolumetricFlowRate) bool [source]¶
Return whether the flow rate is less than or equal to the other.
- __lt__(other: VolumetricFlowRate) bool [source]¶
Return whether the flow rate is less than the other.
- __mod__(other: VolumetricFlowRate) float [source]¶
Return the remainder of the ratio between the flow rate.
- __mul__(value: float) VolumetricFlowRate [source]¶
Return a flow rate scaled by the value.
- __neg__() VolumetricFlowRate [source]¶
Return the inverse of the flow rate.
- __rmul__(value: float) VolumetricFlowRate [source]¶
Return a flow rate scaled by the value.
- __sub__(other: VolumetricFlowRate) VolumetricFlowRate [source]¶
Return the difference of two flow rates.
- __truediv__(other: float | VolumetricFlowRate) VolumetricFlowRate | float [source]¶
Return a scaled flow rate or the ratio between the flow rates.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a flow rate scaled by the inverse of the valueIf the argument is a
VolumetricFlowRate
, return the ratio between the two flow rates
Submodules¶
angle¶
Module for grouping angle-related classes.
- class units.angle.Angle(value: float, unit: Unit)[source]
The opening between two lines in the same plane that meet at a point.
Angle always in range [0, 2*pi) radians.
- __add__(delta: AngleDelta) Angle [source]
Return the sum of the angle and the difference.
- __eq__(other: object) bool [source]
Return whether the objects are equal angles.
- __hash__() int [source]
Return the hash of the length.
- __init__(value: float, unit: Unit) None [source]
Initialise a new angle.
Values outside of the range range [0, 2*pi) radians will be mapped into it.
Range
INITIALIZATION
EQUIVALENT TO
Within
Angle(185, Unit.DEGREE)
Angle(185, Unit.DEGREE)
Below
Angle(-3*math.pi, Unit.RADIAN)
Angle(math.pi, Unit.RADIAN)
Above
Angle(4, Unit.REVOLUTION)
Angle(0, Unit.REVOLUTION)
- __radd__(delta: AngleDelta) Angle [source]
Return the sum of the angle and the difference.
- __sub__(other: Angle | AngleDelta) AngleDelta | Angle [source]
Return the delta between angles or the angle less the delta.
The behaviour depends upon the type of the argument.
If the argument is an angle, return the difference between the two angles.
If the argument is an angle delta, return the angle less the difference.
- as_unit(unit: Unit) float [source]
Return the angle, expressed as the unit.
- class units.angle.AngleDelta(value: float, unit: Unit)[source]
The difference between two angles.
Angle difference always in range [-pi, pi) radians.
- __add__(other: AngleDelta) AngleDelta [source]
Return the sum of the angle differences.
- __eq__(other: object) bool [source]
Return whether the objects are equal angle differences.
- __hash__() int [source]
Return the hash of the angle difference.
- __init__(value: float, unit: Unit) None [source]
Initialise a new angle difference.
Values outside the range [-pi, pi) radians will be mapped into it.
Range
INITIALIZATION
EQUIVALENT TO
Within
AngleDelta(-40, Unit.DEGREE)
AngleDelta(-40, Unit.DEGREE)
Below
AngleDelta(-3*pi, Unit.RADIAN)
AngleDelta(pi, Unit.RADIAN)
Above
AngleDelta(3.75, Unit.REVOLUTION)
AngleDelta(-0.25, Unit.REVOLUTION)
- __neg__() AngleDelta [source]
Return the inverse of the angle difference.
- __sub__(delta: AngleDelta) AngleDelta [source]
Return the difference between the angle differences.
- as_unit(unit: Unit) float [source]
Return the angle difference, expressed as the unit.
- class units.angle.Unit[source]
A angle unit.
NB: Micropython does not yet support enums. The desired behaviour (enumerated options embedded in the type system) can be mostly replicated by substituting IntEnum for object at runtime, which is what has been done here.
- DEGREE = 2
- RADIAN = 1
- REVOLUTION = 3
angular_motion¶
Module for grouping angular-motion-related classes and constants.
- class units.angular_motion.Acceleration(value: float, angle_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None)[source]
The rate of change of the angular velocity of an object wrt time.
- __abs__() Acceleration [source]
Return the absolute version of the angular acceleration.
- __add__(other: Acceleration) Acceleration [source]
Return the sum of two angular accelerations.
- __divmod__(other: Acceleration) tuple[float, float] [source]
Return the quotient & remainder of the ratio tbwn angular accelerations.
- __eq__(other: object) bool [source]
Return whether the objects are equal angular accelerations.
- __floordiv__(other: Acceleration) float [source]
Return the floored ratio between the angular accelerations.
- __ge__(other: Acceleration) bool [source]
Return whether the angular acceleration is greater than or equal to other.
- __gt__(other: Acceleration) bool [source]
Return whether the angular acceleration is greater than the other.
- __hash__() int [source]
Return the hash of the angular acceleration.
- __init__(value: float, angle_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None) None [source]
Initialise a new angular acceleration.
If a second time unit is not provided, the first time unit will be reused.
- __le__(other: Acceleration) bool [source]
Return whether the angular acceleration is less than or equal to other.
- __lt__(other: Acceleration) bool [source]
Return whether the angular acceleration is less than the other.
- __mod__(other: Acceleration) float [source]
Return the remainder of the ratio between the angular acceleration.
- __mul__(value: float) Acceleration [source]
Return an angular acceleration scaled by the value.
- __neg__() Acceleration [source]
Return the inverse of the angular acceleration.
- __rmul__(value: float) Acceleration [source]
Return an angular acceleration scaled by the value.
- __sub__(other: Acceleration) Acceleration [source]
Return the difference of two angular accelerations.
- __truediv__(other: float | Acceleration) Acceleration | float [source]
Return a scaled angular acceleration or the ratio between the accelerations.
The behaviour depends upon the type of the argument.
If the argument is a
float
, return an angular acceleration scaled by the inverse of the valueIf the argument is a
Acceleration
, return the ratio between the two angular accelerations
- as_unit(angle_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None) float [source]
Return the angular acceleration in the specified units.
If a second time unit is not provided, the first time unit will be reused.
- units.angular_motion.AngleUnit
alias of
Unit
- class units.angular_motion.Displacement(value: float, unit: Unit)[source]
The difference between the final & initial position of an angular trajectory.
- __abs__() Displacement [source]
Return the absolute version of the angular displacement.
- __add__(other: Displacement) Displacement [source]
Return the sum of the angular displacements.
- __divmod__(other: Displacement) tuple[float, float] [source]
Return the quotient & remainder of the ratio btwn the displacements.
- __eq__(other: object) bool [source]
Return whether the objects are equal angular displacements.
- __floordiv__(other: Displacement) float [source]
Return the floored ratio between the angular displacements.
- __ge__(other: Displacement) bool [source]
Return whether the angular displacement is greater than or equal to other.
- __gt__(other: Displacement) bool [source]
Return whether the angular displacement is greater than the other.
- __hash__() int [source]
Return the hash of the angular displacement.
- __init__(value: float, unit: Unit) None [source]
Initialise a new angular displacement.
- __le__(other: Displacement) bool [source]
Return whether the angular displacement is less than or equal to other.
- __lt__(other: Displacement) bool [source]
Return whether the angular displacement is less than the other.
- __mod__(other: Displacement) float [source]
Return the remainder of the ratio between the angular displacements.
- __mul__(value: float) Displacement [source]
Return a angular displacement scaled by the value.
- __neg__() Displacement [source]
Return the inverse of the angular displacement.
- __rmul__(value: float) Displacement [source]
Return a angular displacement scaled by the value.
- __sub__(delta: Displacement) Displacement [source]
Return the difference between the angular displacements.
- __truediv__(other: float | Displacement) Displacement | float [source]
Return a scaled angular displacement or the ratio between the displacements.
The behaviour depends upon the type of the argument.
If the argument is scalar, return a angular displacement scaled by the inverse of the value
If the argument is a angular displacement, return the ratio between the two angular displacements
- as_unit(unit: Unit) float [source]
Return the angular displacement, expressed as the unit.
- class units.angular_motion.Jerk(value: float, angle_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None, third_time_unit: Unit | None = None)[source]
The rate of change of the angular jerk of an object with respect to time.
- __abs__() Jerk [source]
Return the absolute version of the angular jerk.
- __add__(other: Jerk) Jerk [source]
Return the sum of two angular jerks.
- __divmod__(other: Jerk) tuple[float, float] [source]
Return the quotient & remainder of the ratio between the angular jerks.
- __eq__(other: object) bool [source]
Return whether the objects are equal angular jerks.
- __floordiv__(other: Jerk) float [source]
Return the floored ratio between the angular jerks.
- __ge__(other: Jerk) bool [source]
Return whether the angular jerk is greater than or equal to the other.
- __gt__(other: Jerk) bool [source]
Return whether the angular jerk is greater than the other.
- __hash__() int [source]
Return the hash of the angular jerk.
- __init__(value: float, angle_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None, third_time_unit: Unit | None = None) None [source]
Initialise a new angular jerk.
If a second time unit is not provided, the first time unit will be reused. If the third time unit is not provided, the second time unit will be reused (or the first, if the second is also not provided).
- __le__(other: Jerk) bool [source]
Return whether the angular jerk is less than or equal to the other.
- __lt__(other: Jerk) bool [source]
Return whether the angular jerk is less than the other.
- __mod__(other: Jerk) float [source]
Return the remainder of the ratio between the angular jerk.
- __mul__(value: float) Jerk [source]
Return an angular jerk scaled by the value.
- __neg__() Jerk [source]
Return the inverse of the angular jerk.
- __rmul__(value: float) Jerk [source]
Return an angular jerk scaled by the value.
- __sub__(other: Jerk) Jerk [source]
Return the difference of two angular jerks.
- __truediv__(other: float | Jerk) Jerk | float [source]
Return a scaled angular jerk or the ratio between the angular jerks.
The behaviour depends upon the type of the argument.
If the argument is a
float
, return an angular jerk scaled by the inverse of the valueIf the argument is a
Jerk
, return the ratio between the two angular jerks
- as_unit(angle_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None, third_time_unit: Unit | None = None) float [source]
Return the angular jerk in the specified units.
If a second time unit is not provided, the first time unit will be reused. If the third time unit is not provided, the second time unit will be reused (or the first, if the second is also not provided).
- units.angular_motion.TimeUnit
alias of
Unit
- class units.angular_motion.Velocity(value: float, angle_unit: Unit, time_unit: Unit)[source]
The rate of change of the angular displacement of an object wrt time.
- __abs__() Velocity [source]
Return the absolute version of the angular velocity.
- __add__(other: Velocity) Velocity [source]
Return the sum of two angular velocities.
- __divmod__(other: Velocity) tuple[float, float] [source]
Return the quotient & remainder of the ratio between the velocities.
- __eq__(other: object) bool [source]
Return whether the objects are equal angular velocities.
- __floordiv__(other: Velocity) float [source]
Return the floored ratio between the angular velocities.
- __ge__(other: Velocity) bool [source]
Return whether the angular velocity is greater than or equal to the other.
- __gt__(other: Velocity) bool [source]
Return whether the angular velocity is greater than the other.
- __hash__() int [source]
Return the hash of the angular velocity.
- __init__(value: float, angle_unit: Unit, time_unit: Unit) None [source]
Initialise a new angular velocity.
- __le__(other: Velocity) bool [source]
Return whether the angular velocity is less than or equal to the other.
- __lt__(other: Velocity) bool [source]
Return whether the angular velocity is less than the other.
- __mod__(other: Velocity) float [source]
Return the remainder of the ratio between the angular velocity.
- __mul__(value: float) Velocity [source]
Return a angular velocity scaled by the value.
- __neg__() Velocity [source]
Return the inverse of the angular velocity.
- __rmul__(value: float) Velocity [source]
Return a angular velocity scaled by the value.
- __sub__(other: Velocity) Velocity [source]
Return the difference of two angular velocities.
- __truediv__(other: float | Velocity) Velocity | float [source]
Return a scaled angular velocity or the ratio between the angular velocities.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a angular velocity scaled by the inverse of the valueIf the argument is a
Velocity
, return the ratio between the two angular velocities
- as_unit(angle_unit: Unit, time_unit: Unit) float [source]
Return the angular velocity in the specified units.
area¶
Module for grouping area-related classes and constants.
- class units.area.Area(value: float, unit: Unit)[source]
The measure of a two-dimensional space.
- __add__(delta: AreaDelta) Area [source]
Return the sum of the area and the difference.
- Raises:
NegativeAreaValueError – The sum of the area and the difference was less than 0m^2.
- __eq__(other: object) bool [source]
Return whether the objects are equal areas.
- __hash__() int [source]
Return the hash of the area.
- __init__(value: float, unit: Unit) None [source]
Initialise a new area.
- Raises:
NegativeAreaValueError – The negative value produced an area less than 0m^2.
- __sub__(other: Area | AreaDelta) AreaDelta | Area [source]
Return the delta between two areas or the area less the delta.
The behaviour depends upon the type of the argument.
If the argument is a
Area
, return the difference between the two areas.If the argument is a
AreaDelta
, return the area less the difference.
- Raises:
NegativeAreaValueError – The area minus the difference was less than 0m^2. Error can only be raised when other is an
AreaDelta
.
- as_unit(unit: Unit) float [source]
Return the area, expressed as the unit.
- class units.area.AreaDelta(value: float, unit: Unit)[source]
The difference between two areas.
- __divmod__(other: AreaDelta) tuple[float, float] [source]
Return the quotient & remainder of the ratio between the area deltas.
- __eq__(other: object) bool [source]
Return whether the objects are equal area differences.
- __floordiv__(other: AreaDelta) float [source]
Return the floored ratio between the area differences.
- __ge__(other: AreaDelta) bool [source]
Return whether the area delta is greater than or equal to the other.
- __gt__(other: AreaDelta) bool [source]
Return whether the area difference is greater than the other.
- __hash__() int [source]
Return the hash of the area difference.
- __init__(value: float, unit: Unit) None [source]
Initialise a new area difference.
- __le__(other: AreaDelta) bool [source]
Return whether the area delta is less than or equal to the other.
- __mod__(other: AreaDelta) float [source]
Return the remainder of the ratio between the area differences.
- __truediv__(other: float | AreaDelta) AreaDelta | float [source]
Return a scaled area difference or the ratio between the differences.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a area difference scaled by the inverse of the valueIf the argument is a
AreaDelta
, return the ratio between the two differences
- as_unit(unit: Unit) float [source]
Return the area difference, expressed as the unit.
- exception units.area.NegativeAreaValueError(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any])[source]
Raised when the area value is negative.
The minimum area that can exist is 0 m^2, so an area with a negative value, regardless of the unit, is impossible.
- __init__(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any]) None [source]
Initialise a new negative-area exception.
- property value: float
The area value that caused the error.
- class units.area.Unit[source]
An area unit.
NB: Micropython does not yet support enums. The desired behaviour (enumerated options embedded in the type system) can be mostly replicated by substituting IntEnum for object at runtime, which is what has been done here.
- SQUARE_CENTIMETRE = 2
- SQUARE_FOOT = 5
- SQUARE_INCH = 6
- SQUARE_METRE = 1
- SQUARE_MILLIMETRE = 3
- SQUARE_YARD = 4
- units.area.ZERO = Area(0, Unit.SQUARE_METRE)¶
Zero area constant.
current¶
Module for grouping current-related classes.
- class units.current.Current(value: float, unit: Unit)[source]
The flow of charged particles through an electrical conductor.
- __divmod__(other: Current) tuple[float, float] [source]
Return the quotient & remainder of the ratio between the currents.
- __eq__(other: object) bool [source]
Return whether the objects are equal currents.
- __ge__(other: Current) bool [source]
Return whether the current is greater than or equal to the other.
- __hash__() int [source]
Return the hash of the current.
- __init__(value: float, unit: Unit) None [source]
Initialise a new current.
- __truediv__(other: float | Current) Current | float [source]
Return a scaled current or the ratio between the currents.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a current scaled by the inverse of the valueIf the argument is a
Current
, return the ratio between the two currents
- as_unit(unit: Unit) float [source]
Return the current, expressed as the unit.
- class units.current.Unit[source]
A current unit.
NB: Micropython does not yet support enums. The desired behaviour (enumerated options embedded in the type system) can be mostly replicated by substituting IntEnum for object at runtime, which is what has been done here.
- AMPERE = 1
- MICROAMPERE = 3
- MILLIAMPERE = 2
flow_rate¶
Module for grouping flow-rate-related classes and constants.
- class units.flow_rate.MassFlowRate(value: float, mass_unit: Unit, time_unit: Unit)[source]
The mass of a gas or liquid that flows in a certain amount of time.
- __abs__() MassFlowRate [source]
Return the absolute version of the flow rate.
- __add__(other: MassFlowRate) MassFlowRate [source]
Return the sum of two flow rates.
- __divmod__(other: MassFlowRate) tuple[float, float] [source]
Return the quotient & remainder of the ratio between the flow rates.
- __eq__(other: object) bool [source]
Return whether the objects are equal flow rates.
- __floordiv__(other: MassFlowRate) float [source]
Return the floored ratio between the flow rates.
- __ge__(other: MassFlowRate) bool [source]
Return whether the flow rate is greater than or equal to the other.
- __gt__(other: MassFlowRate) bool [source]
Return whether the flow rate is greater than the other.
- __hash__() int [source]
Return the hash of the flow rate.
- __init__(value: float, mass_unit: Unit, time_unit: Unit) None [source]
Initialise a new flow rate.
- __le__(other: MassFlowRate) bool [source]
Return whether the flow rate is less than or equal to the other.
- __lt__(other: MassFlowRate) bool [source]
Return whether the flow rate is less than the other.
- __mod__(other: MassFlowRate) float [source]
Return the remainder of the ratio between the flow rate.
- __mul__(value: float) MassFlowRate [source]
Return a flow rate scaled by the value.
- __neg__() MassFlowRate [source]
Return the inverse of the flow rate.
- __rmul__(value: float) MassFlowRate [source]
Return a flow rate scaled by the value.
- __sub__(other: MassFlowRate) MassFlowRate [source]
Return the difference of two flow rates.
- __truediv__(other: float | MassFlowRate) MassFlowRate | float [source]
Return a scaled flow rate or the ratio between the flow rates.
The behaviour depends upon the type of the argument.
If the argument is a
float
, return a flow rate scaled by the inverse of the valueIf the argument is a
MassFlowRate
, return the ratio between the two flow rates
- as_unit(mass_unit: Unit, time_unit: Unit) float [source]
Return the flow rate in the specified units.
- units.flow_rate.MassUnit
alias of
Unit
- units.flow_rate.TimeUnit
alias of
Unit
- units.flow_rate.VolumeUnit
alias of
Unit
- class units.flow_rate.VolumetricFlowRate(value: float, volume_unit: Unit, time_unit: Unit)[source]
The volume of a gas or liquid that flows in a certain amount of time.
- __abs__() VolumetricFlowRate [source]
Return the absolute version of the flow rate.
- __add__(other: VolumetricFlowRate) VolumetricFlowRate [source]
Return the sum of two flow rates.
- __divmod__(other: VolumetricFlowRate) tuple[float, float] [source]
Return the quotient & remainder of the ratio between the flow rates.
- __eq__(other: object) bool [source]
Return whether the objects are equal flow rates.
- __floordiv__(other: VolumetricFlowRate) float [source]
Return the floored ratio between the flow rates.
- __ge__(other: VolumetricFlowRate) bool [source]
Return whether the flow rate is greater than or equal to the other.
- __gt__(other: VolumetricFlowRate) bool [source]
Return whether the flow rate is greater than the other.
- __hash__() int [source]
Return the hash of the flow rate.
- __init__(value: float, volume_unit: Unit, time_unit: Unit) None [source]
Initialise a new flow rate.
- __le__(other: VolumetricFlowRate) bool [source]
Return whether the flow rate is less than or equal to the other.
- __lt__(other: VolumetricFlowRate) bool [source]
Return whether the flow rate is less than the other.
- __mod__(other: VolumetricFlowRate) float [source]
Return the remainder of the ratio between the flow rate.
- __mul__(value: float) VolumetricFlowRate [source]
Return a flow rate scaled by the value.
- __neg__() VolumetricFlowRate [source]
Return the inverse of the flow rate.
- __rmul__(value: float) VolumetricFlowRate [source]
Return a flow rate scaled by the value.
- __sub__(other: VolumetricFlowRate) VolumetricFlowRate [source]
Return the difference of two flow rates.
- __truediv__(other: float | VolumetricFlowRate) VolumetricFlowRate | float [source]
Return a scaled flow rate or the ratio between the flow rates.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a flow rate scaled by the inverse of the valueIf the argument is a
VolumetricFlowRate
, return the ratio between the two flow rates
- as_unit(volume_unit: Unit, time_unit: Unit) float [source]
Return the flow rate in the specified units.
length¶
Module for grouping length-related classes and constants.
- class units.length.Length(value: float, unit: Unit)[source]
The measure of distance.
- __add__(delta: LengthDelta) Length [source]
Return the sum of the length and the difference.
- Raises:
NegativeLengthValueError – The sum of the length and the difference was less than 0m.
- __eq__(other: object) bool [source]
Return whether the objects are equal lengths.
- __ge__(other: Length) bool [source]
Return whether the length is greater than or equal to the other.
- __hash__() int [source]
Return the hash of the length.
- __init__(value: float, unit: Unit) None [source]
Initialise a new length.
- Raises:
NegativeLengthValueError – The negative value produced a length less than 0m.
- __radd__(delta: LengthDelta) Length [source]
Return the sum of the length and the difference.
- __sub__(other: Length | LengthDelta) LengthDelta | Length [source]
Return the delta between lengths or the length less the delta.
The behaviour depends upon the type of the argument.
If the argument is a
Length
, return the difference between the two lengths.If the argument is a
LengthDelta
, return the length less the difference.
- Raises:
NegativeLengthValueError – The length minus the difference was less than 0m. Error can only be raised when other is a
LengthDelta
.
- as_unit(unit: Unit) float [source]
Return the length, expressed as the unit.
- class units.length.LengthDelta(value: float, unit: Unit)[source]
The difference between two lengths.
- __abs__() LengthDelta [source]
Return the absolute version of the length difference.
- __add__(other: LengthDelta) LengthDelta [source]
Return the sum of the length differences.
- __divmod__(other: LengthDelta) tuple[float, float] [source]
Return the quotient & remainder of the ratio between the length deltas.
- __eq__(other: object) bool [source]
Return whether the objects are equal length differences.
- __floordiv__(other: LengthDelta) float [source]
Return the floored ratio between the length differences.
- __ge__(other: LengthDelta) bool [source]
Return whether the length delta is greater than or equal to the other.
- __gt__(other: LengthDelta) bool [source]
Return whether the length difference is greater than the other.
- __hash__() int [source]
Return the hash of the length difference.
- __init__(value: float, unit: Unit) None [source]
Initialise a new length difference.
- __le__(other: LengthDelta) bool [source]
Return whether the length difference is less than or equal to the other.
- __lt__(other: LengthDelta) bool [source]
Return whether the length difference is less than the other.
- __mod__(other: LengthDelta) float [source]
Return the remainder of the ratio between the length differences.
- __mul__(value: float) LengthDelta [source]
Return a length difference scaled by the value.
- __neg__() LengthDelta [source]
Return the inverse of the length difference.
- __rmul__(value: float) LengthDelta [source]
Return a length difference scaled by the value.
- __sub__(delta: LengthDelta) LengthDelta [source]
Return the difference between the length differences.
- __truediv__(other: float | LengthDelta) LengthDelta | float [source]
Return a scaled length difference or the ratio between the differences.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a length difference scaled by the inverse of the valueIf the argument is a
LengthDelta
, return the ratio between the two differences
- as_unit(unit: Unit) float [source]
Return the length difference, expressed as the unit.
- exception units.length.NegativeLengthValueError(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any])[source]
Raised when the length value is negative.
The minimum length that can exist is 0m, so a length with a negative value, regardless of the unit, is impossible.
- __init__(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any]) None [source]
Initialise a new negative-length exception.
- property value: float
The length value that caused the error.
- class units.length.Unit[source]
A distance unit.
NB: Micropython does not yet support enums. The desired behaviour (enumerated options embedded in the type system) can be mostly replicated by substituting IntEnum for object at runtime, which is what has been done here.
- CENTIMETRE = 2
- FOOT = 5
- INCH = 6
- METRE = 1
- MILLIMETRE = 3
- YARD = 4
- units.length.ZERO = Length(0, Unit.METRE)¶
Zero length constant.
linear_motion¶
Module for grouping linear-motion-related classes and constants.
- class units.linear_motion.Acceleration(value: float, distance_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None)[source]
The rate of change of the velocity of an object with respect to time.
- __abs__() Acceleration [source]
Return the absolute version of the acceleration.
- __add__(other: Acceleration) Acceleration [source]
Return the sum of two accelerations.
- __divmod__(other: Acceleration) tuple[float, float] [source]
Return the quotient & remainder of the ratio between the accelerations.
- __eq__(other: object) bool [source]
Return whether the objects are equal accelerations.
- __floordiv__(other: Acceleration) float [source]
Return the floored ratio between the accelerations.
- __ge__(other: Acceleration) bool [source]
Return whether the acceleration is greater than or equal to the other.
- __gt__(other: Acceleration) bool [source]
Return whether the acceleration is greater than the other.
- __hash__() int [source]
Return the hash of the acceleration.
- __init__(value: float, distance_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None) None [source]
Initialise a new acceleration.
If a second time unit is not provided, the first time unit will be reused.
- __le__(other: Acceleration) bool [source]
Return whether the acceleration is less than or equal to the other.
- __lt__(other: Acceleration) bool [source]
Return whether the acceleration is less than the other.
- __mod__(other: Acceleration) float [source]
Return the remainder of the ratio between the acceleration.
- __mul__(value: float) Acceleration [source]
Return an acceleration scaled by the value.
- __neg__() Acceleration [source]
Return the inverse of the acceleration.
- __rmul__(value: float) Acceleration [source]
Return an acceleration scaled by the value.
- __sub__(other: Acceleration) Acceleration [source]
Return the difference of two accelerations.
- __truediv__(other: float | Acceleration) Acceleration | float [source]
Return a scaled acceleration or the ratio between the accelerations.
The behaviour depends upon the type of the argument.
If the argument is a
float
, return an acceleration scaled by the inverse of the valueIf the argument is a
Acceleration
, return the ratio between the two accelerations
- as_unit(distance_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None) float [source]
Return the acceleration in the specified units.
If a second time unit is not provided, the first time unit will be reused.
- class units.linear_motion.Displacement(value: float, unit: Unit)[source]
The difference between the final and initial position of a trajectory.
- __abs__() Displacement [source]
Return the absolute version of the displacement.
- __add__(other: Displacement) Displacement [source]
Return the sum of the displacements.
- __divmod__(other: Displacement) tuple[float, float] [source]
Return the quotient & remainder of the ratio between the displacements.
- __eq__(other: object) bool [source]
Return whether the objects are equal displacements.
- __floordiv__(other: Displacement) float [source]
Return the floored ratio between the displacements.
- __ge__(other: Displacement) bool [source]
Return whether the displacement is greater than or equal to the other.
- __gt__(other: Displacement) bool [source]
Return whether the displacement is greater than the other.
- __hash__() int [source]
Return the hash of the displacement.
- __init__(value: float, unit: Unit) None [source]
Initialise a new displacement.
- __le__(other: Displacement) bool [source]
Return whether the displacement is less than or equal to the other.
- __lt__(other: Displacement) bool [source]
Return whether the displacement is less than the other.
- __mod__(other: Displacement) float [source]
Return the remainder of the ratio between the displacements.
- __mul__(value: float) Displacement [source]
Return a displacement scaled by the value.
- __neg__() Displacement [source]
Return the inverse of the displacement.
- __rmul__(value: float) Displacement [source]
Return a displacement scaled by the value.
- __sub__(delta: Displacement) Displacement [source]
Return the difference between the displacements.
- __truediv__(other: float | Displacement) Displacement | float [source]
Return a scaled displacement or the ratio between the displacements.
The behaviour depends upon the type of the argument.
If the argument is a
float
, return a displacement scaled by the inverse of the valueIf the argument is a
Displacement
, return the ratio between the two displacements
- as_unit(unit: Unit) float [source]
Return the displacement, expressed as the unit.
- units.linear_motion.DistanceUnit
alias of
Unit
- class units.linear_motion.Jerk(value: float, distance_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None, third_time_unit: Unit | None = None)[source]
The rate of change of the jerk of an object with respect to time.
- __divmod__(other: Jerk) tuple[float, float] [source]
Return the quotient & remainder of the ratio between the jerks.
- __eq__(other: object) bool [source]
Return whether the objects are equal jerks.
- __hash__() int [source]
Return the hash of the jerk.
- __init__(value: float, distance_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None, third_time_unit: Unit | None = None) None [source]
Initialise a new jerk.
If a second time unit is not provided, the first time unit will be reused. If the third time unit is not provided, the second time unit will be reused (or the first, if the second is also not provided).
- __truediv__(other: float | Jerk) Jerk | float [source]
Return a scaled jerk or the ratio between the jerks.
The behaviour depends upon the type of the argument.
If the argument is a
float
, return an jerk scaled by the inverse of the valueIf the argument is a
Jerk
, return the ratio between the two jerks
- as_unit(distance_unit: Unit, first_time_unit: Unit, second_time_unit: Unit | None = None, third_time_unit: Unit | None = None) float [source]
Return the jerk in the specified units.
If a second time unit is not provided, the first time unit will be reused. If the third time unit is not provided, the second time unit will be reused (or the first, if the second is also not provided).
- units.linear_motion.TimeUnit
alias of
Unit
- class units.linear_motion.Velocity(value: float, distance_unit: Unit, time_unit: Unit)[source]
The rate of change of the displacement of an object wrt time.
- __divmod__(other: Velocity) tuple[float, float] [source]
Return the quotient & remainder of the ratio between the velocities.
- __eq__(other: object) bool [source]
Return whether the objects are equal velocities.
- __ge__(other: Velocity) bool [source]
Return whether the velocity is greater than or equal to the other.
- __hash__() int [source]
Return the hash of the velocity.
- __init__(value: float, distance_unit: Unit, time_unit: Unit) None [source]
Initialise a new velocity.
- __le__(other: Velocity) bool [source]
Return whether the velocity is less than or equal to the other.
- __truediv__(other: float | Velocity) Velocity | float [source]
Return a scaled velocity or the ratio between the velocities.
The behaviour depends upon the type of the argument.
If the argument is a
float
, return a velocity scaled by the inverse of the valueIf the argument is a
Velocity
, return the ratio between the two velocities
- as_unit(distance_unit: Unit, time_unit: Unit) float [source]
Return the velocity in the specified units.
mass¶
Module for grouping mass-related classes and constants.
- class units.mass.Mass(value: float, unit: Unit)[source]
The force applied per unit area over which that force is distributed.
- __add__(delta: MassDelta) Mass [source]
Return the sum of the mass and the difference.
- Raises:
NegativeMassValueError – The sum of the mass and the difference was less than 0kg.
- __eq__(other: object) bool [source]
Return whether the objects are equal masses.
- __hash__() int [source]
Return the hash of the mass.
- __init__(value: float, unit: Unit) None [source]
Initialise a new mass.
- Raises:
NegativeMassValueError – The negative value produced a mass less than 0kg.
- __sub__(other: Mass | MassDelta) MassDelta | Mass [source]
Return the delta between mass or the mass less the delta.
The behaviour depends upon the type of the argument.
If the argument is a
Mass
, return the difference between the two masses.If the argument is a
MassDelta
, return the mass less the difference.
- Raises:
NegativeMassValueError – The mass minus the difference was less than 0kg. Only possible when other is a MassDelta.
- as_unit(unit: Unit) float [source]
Return the mass, expressed as the unit.
- class units.mass.MassDelta(value: float, unit: Unit)[source]
The difference between two masses.
- __divmod__(other: MassDelta) tuple[float, float] [source]
Return the quotient & remainder of the ratio between the mass deltas.
- __eq__(other: object) bool [source]
Return whether the objects are equal mass differences.
- __floordiv__(other: MassDelta) float [source]
Return the floored ratio between the mass differences.
- __ge__(other: MassDelta) bool [source]
Return whether the mass delta is greater than or equal to the other.
- __gt__(other: MassDelta) bool [source]
Return whether the mass difference is greater than the other.
- __hash__() int [source]
Return the hash of the mass difference.
- __init__(value: float, unit: Unit) None [source]
Initialise a new mass difference.
- __le__(other: MassDelta) bool [source]
Return whether the mass delta is less than or equal to the other.
- __mod__(other: MassDelta) float [source]
Return the remainder of the ratio between the mass differences.
- __truediv__(other: float | MassDelta) MassDelta | float [source]
Return a scaled mass difference or the ratio between the differences.
The behaviour depends upon the type of the argument.
If the argument is a
float
, return a mass difference scaled by the inverse of the valueIf the argument is a
MassDelta
, return the ratio between the two differences
- as_unit(unit: Unit) float [source]
Return the mass difference, expressed as the unit.
- exception units.mass.NegativeMassValueError(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any])[source]
Raised when the mass value is negative.
The minimum mass that can exist is 0 kg, so a mass with a negative value, regardless of the unit, is impossible.
- __init__(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any]) None [source]
Initialise a new negative-mass exception.
- property value: float
The mass value that caused the error.
- class units.mass.Unit[source]
A mass unit.
NB: Micropython does not yet support enums. The desired behaviour (enumerated options embedded in the type system) can be mostly replicated by substituting IntEnum for object at runtime, which is what has been done here.
- GRAM = 2
- KILOGRAM = 1
- MILLIGRAM = 3
- OUNCE = 5
- POUND = 4
- units.mass.ZERO = Mass(0, Unit.KILOGRAM)¶
Zero mass constant.
pressure¶
Module for grouping pressure-related classes and constants.
- exception units.pressure.NegativePressureValueError(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any])[source]
Raised when the pressure value is negative.
The minimum pressure that can exist is a perfect vacuum (0 Pa), so a pressure with a negative value, regardless of the unit, is impossible.
- __init__(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any]) None [source]
Initialise a new negative-pressure exception.
- property value: float
The pressure value that caused the error.
- class units.pressure.Pressure(value: float, unit: Unit)[source]
The force applied per unit area over which that force is distributed.
- __add__(delta: PressureDelta) Pressure [source]
Return the sum of the pressure and the difference.
- Raises:
NegativePressureValueError – The sum of the pressure and the difference was less than 0Pa.
- __eq__(other: object) bool [source]
Return whether the objects are equal pressures.
- __ge__(other: Pressure) bool [source]
Return whether the pressure is greater than or equal to the other.
- __hash__() int [source]
Return the hash of the pressure.
- __init__(value: float, unit: Unit) None [source]
Initialise a new pressure.
- Raises:
NegativePressureValueError – The negative value produced a pressure less than 0Pa.
- __le__(other: Pressure) bool [source]
Return whether the pressure is less than or equal to the other.
- __radd__(delta: PressureDelta) Pressure [source]
Return the sum of the pressure and the difference.
- __sub__(other: Pressure | PressureDelta) PressureDelta | Pressure [source]
Return the delta between pressures or the pressure less the delta.
The behaviour depends upon the type of the argument.
If the argument is a
Pressure
, return the difference between the two pressures.If the argument is a
PressureDelta
, return the pressure less the difference.
- Raises:
NegativePressureValueError – The pressure minus the difference was less than 0Pa. Error can only be raised when other is a
PressureDelta
.
- as_unit(unit: Unit) float [source]
Return the pressure, expressed as the unit.
- class units.pressure.PressureDelta(value: float, unit: Unit)[source]
The difference between two pressures.
- __abs__() PressureDelta [source]
Return the absolute version of the pressure difference.
- __add__(other: PressureDelta) PressureDelta [source]
Return the sum of the pressure differences.
- __divmod__(other: PressureDelta) tuple[float, float] [source]
Return the quotient & remainder of the ratio between the pressure deltas.
- __eq__(other: object) bool [source]
Return whether the objects are equal pressure differences.
- __floordiv__(other: PressureDelta) float [source]
Return the floored ratio between the pressure differences.
- __ge__(other: PressureDelta) bool [source]
Return whether the pressure delta is greater than or equal to the other.
- __gt__(other: PressureDelta) bool [source]
Return whether the pressure difference is greater than the other.
- __hash__() int [source]
Return the hash of the pressure difference.
- __init__(value: float, unit: Unit) None [source]
Initialise a new pressure difference.
- __le__(other: PressureDelta) bool [source]
Return whether the pressure delta is less than or equal to the other.
- __lt__(other: PressureDelta) bool [source]
Return whether the pressure difference is less than the other.
- __mod__(other: PressureDelta) float [source]
Return the remainder of the ratio between the pressure differences.
- __mul__(value: float) PressureDelta [source]
Return a pressure difference scaled by the value.
- __neg__() PressureDelta [source]
Return the inverse of the pressure difference.
- __rmul__(value: float) PressureDelta [source]
Return a pressure difference scaled by the value.
- __sub__(delta: PressureDelta) PressureDelta [source]
Return the difference between the pressure differences.
- __truediv__(other: float | PressureDelta) PressureDelta | float [source]
Return a scaled pressure difference or the ratio between the differences.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a pressure difference scaled by the inverse of the valueIf the argument is a
PressureDelta
, return the ratio between the two differences
- as_unit(unit: Unit) float [source]
Return the pressure difference, expressed as the unit.
- class units.pressure.Unit[source]
A pressure unit.
NB: Micropython does not yet support enums. The desired behaviour (enumerated options embedded in the type system) can be mostly replicated by substituting IntEnum for object at runtime, which is what has been done here.
- ATMOSPHERE = 4
- BAR = 3
- KILOPASCAL = 6
- MILLIBAR = 7
- MILLIMETRE_OF_MERCURY = 5
- PASCAL = 1
- POUND_PER_SQUARE_INCH = 2
- units.pressure.PERFECT_VACUUM = Pressure(0, Unit.PASCAL)¶
Perfect vacuum pressure constant.
- units.pressure.STANDARD_ATMOSPHERE = Pressure(101325, Unit.PASCAL)¶
Standard atmospheric pressure constant.
temperature¶
Module for grouping temperature-related classes and constants.
- exception units.temperature.BelowAbsoluteZeroError(value: float, unit: Unit, *args: tuple[Any, ...], **kwargs: dict[str, Any])[source]
Raised when the temperature would be less than absolute zero.
The minimum temperature that can exist is absolute zero (0 K), so a temperature less than this is impossible.
- __init__(value: float, unit: Unit, *args: tuple[Any, ...], **kwargs: dict[str, Any]) None [source]
Initialise a new below-absolute-zero exception.
- property unit: Unit
The temperature unit that caused the error.
- property value: float
The temperature value that caused the error.
- class units.temperature.Temperature(value: float, unit: Unit)[source]
Quantitatively expresses the attribute of hotness or coldness.
- __add__(delta: TemperatureDelta) Temperature [source]
Return the sum of the temperature and the difference.
- Raises:
BelowAbsoluteZeroError – The sum of the temperature and the difference was less than absolute zero.
- __eq__(other: object) bool [source]
Return whether the objects are equal temperatures.
- __ge__(other: Temperature) bool [source]
Return whether the temperature is greater than or equal to the other.
- __gt__(other: Temperature) bool [source]
Return whether the temperature is greater than the other.
- __hash__() int [source]
Return the hash of the temperature.
- __init__(value: float, unit: Unit) None [source]
Initialise a new temperature.
- Raises:
BelowAbsoluteZeroError – The value and unit produced an invalid temperature less than absolute zero.
- __le__(other: Temperature) bool [source]
Return whether the temperature is less than or equal to the other.
- __lt__(other: Temperature) bool [source]
Return whether the temperature is less than the other.
- __radd__(delta: TemperatureDelta) Temperature [source]
Return the sum of the temperature and the difference.
- __sub__(other: Temperature | TemperatureDelta) TemperatureDelta | Temperature [source]
Return the delta between temperatures or the temperature less the delta.
The behaviour depends upon the type of the argument.
If the argument is a
Temperature
, return the difference between the two temperatures.If the argument is a
TemperatureDelta
, return the temperature less the difference.
- Raises:
BelowAbsoluteZeroError – The temperature minus the difference was less than absolute zero.Error can only be raised when other is a
TemperatureDelta
.
- as_unit(unit: Unit) float [source]
Return the temperature, expressed as the unit.
- class units.temperature.TemperatureDelta(value: float, unit: Unit)[source]
The difference between two temperatures.
- __abs__() TemperatureDelta [source]
Return the absolute version of the temperature difference.
- __add__(other: TemperatureDelta) TemperatureDelta [source]
Return the sum of the temperature differences.
- __divmod__(other: TemperatureDelta) tuple[float, float] [source]
Return the quotient and remainder of the ratio between the temp deltas.
- __eq__(other: object) bool [source]
Return whether the objects are equal temperature differences.
- __floordiv__(other: TemperatureDelta) float [source]
Return the floored ratio between the temperature differences.
- __ge__(other: TemperatureDelta) bool [source]
Return whether the temperature delta is greater than or equal to other.
- __gt__(other: TemperatureDelta) bool [source]
Return whether the temperature difference is greater than the other.
- __hash__() int [source]
Return the hash of the temperature difference.
- __init__(value: float, unit: Unit) None [source]
Initialise a new temperature difference.
- __le__(other: TemperatureDelta) bool [source]
Return whether the temperature delta is less than or equal to the other.
- __lt__(other: TemperatureDelta) bool [source]
Return whether the temperature difference is less than the other.
- __mod__(other: TemperatureDelta) float [source]
Return the remainder of the ratio between the temperature differences.
- __mul__(value: float) TemperatureDelta [source]
Return a temperature difference scaled by the value.
- __neg__() TemperatureDelta [source]
Return the inverse of the temperature difference.
- __rmul__(value: float) TemperatureDelta [source]
Return a temperature difference scaled by the value.
- __sub__(delta: TemperatureDelta) TemperatureDelta [source]
Return the difference between the temperature differences.
- __truediv__(other: float | TemperatureDelta) TemperatureDelta | float [source]
Return a scaled temperature difference or the ratio between the differences.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a temperature difference scaled by the inverse of the valueIf the argument is a
TemperatureDelta
, return the ratio between the two differences
- as_unit(unit: Unit) float [source]
Return the temperature difference, expressed as the unit.
- class units.temperature.Unit[source]
A temperature unit.
NB: Micropython does not yet support enums. The desired behaviour (enumerated options embedded in the type system) can be mostly replicated by substituting IntEnum for object at runtime, which is what has been done here.
- CELSIUS = 1
- FAHRENHEIT = 3
- KELVIN = 2
- units.temperature.ABSOLUTE_ZERO = Temperature(0, Unit.KELVIN)¶
Absolute zero temperature constant.
time¶
Module for grouping time-related classes and constants.
- exception units.time.NegativeTimeValueError(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any])[source]
Raised when the time value is negative.
The minimum time that can exist is 0s, so a time with a negative value, regardless of the unit, is impossible.
- __init__(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any]) None [source]
Initialise a new negative-time exception.
- property value: float
The time value that caused the error.
- class units.time.Time(value: float, unit: Unit)[source]
The measure in which events can be ordered from the past into the future.
- __add__(delta: TimeDelta) Time [source]
Return the sum of the time and the difference.
- Raises:
NegativeTimeValueError – The sum of the time and the difference was less than 0s.
- __eq__(other: object) bool [source]
Return whether the objects are equal times.
- __hash__() int [source]
Return the hash of the time.
- __init__(value: float, unit: Unit) None [source]
Initialise a new time.
- Raises:
NegativeTimeValueError – The negative value produced a time less than 0s.
- __sub__(other: Time | TimeDelta) TimeDelta | Time [source]
Return the delta between times or the time less the delta.
The behaviour depends upon the type of the argument.
If the argument is a
Time
, return the difference between the two times.If the argument is a
TimeDelta
, return the time less the difference.
- Raises:
NegativeTimeValueError – The time minus the difference was less than 0s. Error can only be raised when other is a
TimeDelta
.
- as_unit(unit: Unit) float [source]
Return the time, expressed as the unit.
- class units.time.TimeDelta(value: float, unit: Unit)[source]
The difference between two times.
- __divmod__(other: TimeDelta) tuple[float, float] [source]
Return the quotient & remainder of the ratio between the time deltas.
- __eq__(other: object) bool [source]
Return whether the objects are equal time differences.
- __floordiv__(other: TimeDelta) float [source]
Return the floored ratio between the time differences.
- __ge__(other: TimeDelta) bool [source]
Return whether the time delta is greater than or equal to the other.
- __gt__(other: TimeDelta) bool [source]
Return whether the time difference is greater than the other.
- __hash__() int [source]
Return the hash of the time difference.
- __init__(value: float, unit: Unit) None [source]
Initialise a new time difference.
- __le__(other: TimeDelta) bool [source]
Return whether the time delta is less than or equal to the other.
- __mod__(other: TimeDelta) float [source]
Return the remainder of the ratio between the time differences.
- __truediv__(other: float | TimeDelta) TimeDelta | float [source]
Return a scaled time difference or the ratio between the differences.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a time difference scaled by the inverse of the valueIf the argument is a
TimeDelta
, return the ratio between the two differences
- as_unit(unit: Unit) float [source]
Return the time difference, expressed as the unit.
- class units.time.Unit[source]
A time unit.
NB: Micropython does not yet support enums. The desired behaviour (enumerated options embedded in the type system) can be mostly replicated by substituting IntEnum for object at runtime, which is what has been done here.
- HOUR = 3
- MICROSECOND = 4
- MILLISECOND = 5
- MINUTE = 2
- SECOND = 1
- units.time.ZERO = Time(0, Unit.SECOND)¶
Zero elapsed time constant.
voltage¶
Module for grouping voltage-related classes.
- class units.voltage.Unit[source]
A voltage unit.
NB: Micropython does not yet support enums. The desired behaviour (enumerated options embedded in the type system) can be mostly replicated by substituting IntEnum for object at runtime, which is what has been done here.
- MICROVOLT = 3
- MILLIVOLT = 2
- VOLT = 1
- class units.voltage.Voltage(value: float, unit: Unit)[source]
The difference in electric potential between two points.
- __divmod__(other: Voltage) tuple[float, float] [source]
Return the quotient & remainder of the ratio between the voltages.
- __eq__(other: object) bool [source]
Return whether the objects are equal voltages.
- __ge__(other: Voltage) bool [source]
Return whether the voltage is greater than or equal to the other.
- __hash__() int [source]
Return the hash of the voltage.
- __init__(value: float, unit: Unit) None [source]
Initialise a new voltage.
- __truediv__(other: float | Voltage) Voltage | float [source]
Return a scaled voltage or the ratio between the voltages.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a voltage scaled by the inverse of the valueIf the argument is a
Voltage
, return the ratio between the two voltages
- as_unit(unit: Unit) float [source]
Return the voltage, expressed as the unit.
volume¶
Module for grouping volume-related classes and constants.
- exception units.volume.NegativeVolumeValueError(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any])[source]
Raised when the volume value is negative.
The minimum volume that can exist is 0 m^3, so a volume with a negative value, regardless of the unit, is impossible.
- __init__(value: float, *args: tuple[Any, ...], **kwargs: dict[str, Any]) None [source]
Initialise a new negative-volume exception.
- property value: float
The volume value that caused the error.
- class units.volume.Unit[source]
A volume unit.
NB: Micropython does not yet support enums. The desired behaviour (enumerated options embedded in the type system) can be mostly replicated by substituting IntEnum for object at runtime, which is what has been done here.
- CUBIC_METRE = 1
- LITRE = 2
- MICROLITRE = 4
- MILLILITRE = 3
- class units.volume.Volume(value: float, unit: Unit)[source]
The measure of a three-dimensional space.
- __add__(delta: VolumeDelta) Volume [source]
Return the sum of the volume and the difference.
- Raises:
NegativeVolumeValueError – The sum of the volume and the difference was less than 0m^3.
- __eq__(other: object) bool [source]
Return whether the objects are equal volumes.
- __ge__(other: Volume) bool [source]
Return whether the volume is greater than or equal to the other.
- __hash__() int [source]
Return the hash of the volume.
- __init__(value: float, unit: Unit) None [source]
Initialise a new volume.
- Raises:
NegativeVolumeValueError – The negative value produced a volume less than 0m^3.
- __radd__(delta: VolumeDelta) Volume [source]
Return the sum of the volume and the difference.
- __sub__(other: Volume | VolumeDelta) VolumeDelta | Volume [source]
Return the delta between volumes or the volume less the delta.
The behaviour depends upon the type of the argument.
If the argument is a
Volume
, return the difference between the two volumes.If the argument is a
VolumeDelta
, return the volume less the difference.
- Raises:
NegativeVolumeValueError – The volume minus the difference was less than 0m^3. Error can only be raised when other is a
VolumeDelta
.
- as_unit(unit: Unit) float [source]
Return the volume, expressed as the unit.
- class units.volume.VolumeDelta(value: float, unit: Unit)[source]
The difference between two volumes.
- __abs__() VolumeDelta [source]
Return the absolute version of the volume difference.
- __add__(other: VolumeDelta) VolumeDelta [source]
Return the sum of the volume differences.
- __divmod__(other: VolumeDelta) tuple[float, float] [source]
Return the quotient & remainder of the ratio between the volume deltas.
- __eq__(other: object) bool [source]
Return whether the objects are equal volume differences.
- __floordiv__(other: VolumeDelta) float [source]
Return the floored ratio between the volume differences.
- __ge__(other: VolumeDelta) bool [source]
Return whether the volume delta is greater than or equal to the other.
- __gt__(other: VolumeDelta) bool [source]
Return whether the volume difference is greater than the other.
- __hash__() int [source]
Return the hash of the volume difference.
- __init__(value: float, unit: Unit) None [source]
Initialise a new volume difference.
- __le__(other: VolumeDelta) bool [source]
Return whether the volume delta is less than or equal to the other.
- __lt__(other: VolumeDelta) bool [source]
Return whether the volume difference is less than the other.
- __mod__(other: VolumeDelta) float [source]
Return the remainder of the ratio between the volume differences.
- __mul__(value: float) VolumeDelta [source]
Return a volume difference scaled by the value.
- __neg__() VolumeDelta [source]
Return the inverse of the volume difference.
- __rmul__(value: float) VolumeDelta [source]
Return a volume difference scaled by the value.
- __sub__(delta: VolumeDelta) VolumeDelta [source]
Return the difference between the volume differences.
- __truediv__(other: float | VolumeDelta) VolumeDelta | float [source]
Return a scaled volume difference or the ratio between the differences.
The behaviour depends upon the type of the argument.
If the argument is
float
, return a volume difference scaled by the inverse of the valueIf the argument is a
VolumeDelta
, return the ratio between the two differences
- as_unit(unit: Unit) float [source]
Return the volume difference, expressed as the unit.
- units.volume.ZERO = Volume(0, Unit.CUBIC_METRE)¶
Zero volume constant.