stravalib.model.Velocity#
- class stravalib.model.Velocity(x=0, /)[source]#
- A class for representing velocities as quantities (using meters per second as unit, which is the implicit default of Strava). These quantities can then
be converted to other units such as km/h or mph using the stravalib.unit_helper module.
Examples
>>> from stravalib import unit_helper >>> activity = client.get_activity(11854593990) >>> activity.average_speed 3.53 >>> activity.average_speed.quantity() <Quantity(3.53, 'meter / second')> >>> unit_helper.miles_per_hour(activity.average_speed) <Quantity(7.89638511, 'mile / hour')> >>> unit_helper.miles_per_hour(activity.average_speed).magnitude 7.896385110952039
- __init__()#
Methods
fromhex()Create a floating-point number from a hexadecimal string.
hex()Return a hexadecimal representation of a floating-point number.
Return True if the float is an integer.
quantity()Returns the base type (e.g., float) as a pint.Quantity by attaching the unit to it.
Attributes
The quantity's unit
- fromhex()#
Create a floating-point number from a hexadecimal string.
>>> float.fromhex('0x1.ffffp10') 2047.984375 >>> float.fromhex('-0x1p-1074') -5e-324
- hex()#
Return a hexadecimal representation of a floating-point number.
>>> (-0.1).hex() '-0x1.999999999999ap-4' >>> 3.14159.hex() '0x1.921f9f01b866ep+1'
- is_integer()#
Return True if the float is an integer.
- quantity() Quantity#
Returns the base type (e.g., float) as a pint.Quantity by attaching the unit to it.
- unit: str = 'meters/second'#
The quantity’s unit