ScaleInterval¶
-
class
whalrus.
ScaleInterval
(low: numbers.Number = 0, high: numbers.Number = 1)[source]¶ A scale given by a continuous interval of numbers.
- Parameters
low (Number) – Lowest grade.
high (Number) – Highest grade.
Examples
>>> ScaleInterval(low=0, high=2.5) ScaleInterval(low=0, high=Fraction(5, 2))
-
argsort
(some_list: list, reverse: bool = False) → list[source]¶ Examples
>>> ScaleInterval(low=0, high=1).argsort([.3, .1, .7]) [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
>>> ScaleInterval(low=0, high=1).high 1
-
property
low
¶ Examples
>>> ScaleInterval(low=0, high=1).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
-
max
(iterable: Iterable) → object[source]¶ Examples
>>> ScaleInterval(low=0, high=1).max([.3, .1, .7]) 0.7