stravalib.unit_helper._Quantity#

class stravalib.unit_helper._Quantity(x=0, /)[source]#

Subtype of float that can represent quantities by adding a unit

__init__()#

Methods

fromhex()

Create a floating-point number from a hexadecimal string.

hex()

Return a hexadecimal representation of a floating-point number.

is_integer()

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

unit

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[source]#

Returns the base type (e.g., float) as a pint.Quantity by attaching the unit to it.

unit: str#

The quantity’s unit