Speed
- class pydsol.core.units.Speed(value, unit: str | None = None, **kwargs)[source]
-
- __init__(value: float, unit: str | None = None, **kwargs)
Create a Quantity instance of the right type. The si-value of the quantity is stored in the float that Quantity subclasses, so internally all values are stored in their base-unit, which is most often the si-unit.
- Raises:
ValueError – when the provided unit is not defined for this quantity, or when value is not a number
- asSI()
Return the value of this quantity as an instance of type SI. A speed of 10 m/s will therefore be instantiates as SI(10, ‘m/s’).
- as_unit(newunit: str) Q
Return a new quantity that has been transformed to the new unit. The instantiation avoids multiplication and division for the allocation to the new unit as would be the case in: return self.instantiate(float(self) / self.units()[newunit], newunit). Instead, the internal si-value is copied into the return value and the unit is adapted to the new unit. This means that the two quantities Length(3.4, ‘mi’).si and Length(3.4, ‘mi’).as_unit(‘mm’).si are exactly the same without rounding errors.
- Raises:
ValueError – when newunit is not defined for this quantity
- property displayvalue: float
Return the display value of the quantity. So, for Length(14, ‘cm’) the displayvalue is 14.
- property si: float
Return the internal unit (often, but not always, si) value of the quantity. So, for Length(14, ‘cm’) si is 0.14, since the base si unit is meters.
- static sidict_to_unit(sistr: Dict[str, int], div: bool = True, hat: str = '', dot: str = '') str
Static method to return a string with the SI-signature for a dict of SI quantities with their indices, such as {‘m’:1, ‘s’:-1} for Speed, equivalent to m/s;
- Parameters:
sistr – The SI information that maps SI quantity strings on the index to use. Valid quantity strings are ‘rad’, ‘sr’, ‘kg’, ‘m’, ‘s’, ‘A’, ‘K’, ‘mol’, and ‘cd’. These are the 7 SI units plus ‘rad’ and ‘sr’ for angles for reasons of clarity.
div – Defines whether to use a divisor (when div == True) or negative indices for the SI units (when div == False). When div is true, Force returns kgm/s2; when it is false, it returns kgms-2.
hat – Defines the hat sign to use for indices larger than 1. When set to ‘^’, Energy would return kgm^2/s^2. When left blank, kgm2/s2.
dot – Defines the dot sign to use between quantities. When set to ‘.’, ElectricalResistance would return kg.m2/s3.A2. When left blank, kgm2/s3A2. Combined with hat=’^’: kg.m^2/s^3.A^2
- classmethod sisig() List[int]
Return a list with the SI-exponents of this quantity, independent of the unit. Speed will, e.g., return [0, 0, 0, 1, -1, 0, 0, 0, 0]. Note that this is not defined as a property method. Property class methods were introduced in Python 3.9, where we want this library to be compatible with Python 3.8 for now.
- classmethod siunit(div: bool = True, hat: str = '', dot: str = '') str
Return a string with the SI-signature of this quantity, independent of the actual unit. Speed will, e.g., return m/s;
- Parameters:
div – Defines whether to use a divisor (when div == True) or negative indices for the SI units (when div == False). When div is true, Force returns kgm/s2; when it is false, it returns kgms-2.
hat – Defines the hat sign to use for indices larger than 1. When set to ‘^’, Energy would return kgm^2/s^2. When left blank, kgm2/s2.
dot – Defines the dot sign to use between quantities. When set to ‘.’, ElectricalResistance would return kg.m2/s3.A2. When left blank, kgm2/s3A2. Combined with hat=’^’: kg.m^2/s^3.A^2
- property unit: str
Return the unit with which the quantity was defined. So, for Length(14, ‘cm’) the unit is ‘cm’. Note that the unit is different from the displayunit. For Length(14, ‘mum’), the unit is ‘mum’, but the displayunit is μm where μ stands for mu (micro).
- class pydsol.core.units.SpeedDist(wrapped_distribution: Distribution, unit: str)[source]
Bases:
QuantityDist
Probability distribution for Speed quantity
- __init__(wrapped_distribution: Distribution, unit: str)
Create a random distribution function that returns a quantity.