ScaleRange¶
-
class
whalrus.
ScaleRange
(low: int, high: int)[source]¶ A scale of consecutive integers.
Remark: for a scale of non-consecutive integers, such as {-1, 0, 2}, use the
ScaleFromSet
.- Parameters
low (int) – Lowest integer.
high (int) – Highest integer.
Examples
>>> scale = ScaleRange(low=0, high=5)
-
argsort
(some_list: list, reverse: bool = False) → list[source]¶ Examples
>>> ScaleRange(low=0, high=5).argsort([3, 1, 4]) [1, 0, 2]
-
compare
(one: object, another: object) → int¶ Compare two levels.
- Parameters
one (object) – A level.
another (object) – A level.
- Returns
0 if they are equal, a positive number if
one
is greater thananother
, a negative number otherwise.- Return type
int
Examples
>>> Scale().compare('a', 'z') -1
-
property
high
¶ Examples
>>> ScaleRange(low=0, high=5).high 5
-
property
low
¶ Examples
>>> ScaleRange(low=0, high=5).low 0
-
lt
(one: object, another: object) → bool¶ Test “lower than”.
Generally, only this method is overridden in the subclasses.
- Parameters
one (object) – A level of the scale.
another (object) – A level of the scale.
- Returns
True iff
one
is lower thananother
.- Return type
bool
Examples
>>> Scale().lt('a', 'z') True