Range class, for creating instances of Range objects.
Contains a few documented methods and a number of __*__ methods implementing arithmetic operations. Precise numeric types such as int and Fraction may also occur in some arithmetic expressions, but all occurrances of floating point and Decimal numbers in arithmetic expressions will cause an exception to be raised.
Bases: object
Class for instantiating Range objects.
Return a representation of this size, decomposed into a Fraction value and a unit specifier tuple.
Parameters: | config (ValueConfig) – configuration |
---|---|
Returns: | a pair of a decimal value and a unit |
Return type: | tuple of Fraction and unit |
Raises RangeValueError: | |
if min_value is not usable |
The meaning of the parameters is the same as for _config.ValueConfig.
Yield a representation of this size for every unit, decomposed into a Fraction value and a unit specifier tuple.
Parameters: | binary_units (bool) – binary units if True, else SI |
---|
Return the size in the units indicated by the specifier.
Parameters: | spec (a units specifier or Range) – a units specifier |
---|---|
Returns: | a numeric value in the units indicated by the specifier |
Return type: | fractions.Fraction |
Raises RangeValueError: | |
if unit specifier is non-positive |
Return a string representation of the size.
Parameters: | config (StringConfig) – the configuration |
---|---|
Returns: | a string representation |
Return type: | str |
Raises RangeValueError: | |
if configuration is not satisfiable |
Return a representation of the size.
Parameters: | config (ValueConfig) – representation configuration |
---|---|
Returns: | a tuple representing the number to display |
Return type: | tuple of Radix * int * unit |
Returns: | the number of bytes |
---|---|
Return type: | Fraction |
Rounds to unit specified as a named constant or a Range.
Parameters: |
|
---|---|
Returns: | appropriately rounded Range |
Return type: | |
Raises RangeValueError: | |
on unusable arguments |
If unit is Range(0), returns Range(0).
Note that rounding may be in the opposite direction of the rounding method, e.g., when the rounding method is ROUND_DOWN but the current value is below the lower bound the ultimate direction of the rounding will be up.