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 than another, a negative number otherwise.

Return type:

int

Examples

>>> Scale().compare('a', 'z')
-1
eq(one: object, another: object) → bool

Test “equal”. Cf. lt().

ge(one: object, another: object) → bool

Test “greater or equal”. Cf. lt().

gt(one: object, another: object) → bool

Test “greater than”. Cf. lt().

high

Examples

>>> ScaleInterval(low=0, high=1).high
1
le(one: object, another: object) → bool

Test “lower or equal”. Cf. lt().

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 than another.

Return type:

bool

Examples

>>> Scale().lt('a', 'z')
True
max(iterable: Iterable[T_co]) → object[source]

Examples

>>> ScaleInterval(low=0, high=1).max([.3, .1, .7])
0.7
min(iterable: Iterable[T_co]) → object[source]

Examples

>>> ScaleInterval(low=0, high=1).min([.3, .1, .7])
0.1
ne(one: object, another: object) → bool

Test “not equal”. Cf. lt().

sort(some_list: list, reverse: bool = False) → None[source]

Examples

>>> some_list = [.3, .1, .7]
>>> ScaleInterval(low=0, high=1).sort(some_list)
>>> some_list
[0.1, 0.3, 0.7]