ScaleFromList¶
-
class
whalrus.ScaleFromList(levels: list)[source]¶ Scale derived from a list.
Parameters: levels (list) – The list of levels, from the worst to the best. -
argsort(some_list: list, reverse: bool = False) → list[source]¶ Examples
>>> scale = ScaleFromList(['Bad', 'Medium', 'Good', 'Very good', 'Excellent']) >>> scale.argsort(['Good', 'Bad', 'Excellent']) [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
oneis greater thananother, a negative number otherwise.Return type: int
Examples
>>> Scale().compare('a', 'z') -1
-
high¶ >>> scale = ScaleFromList(['Bad', 'Medium', 'Good', 'Very good', 'Excellent']) >>> scale.high 'Excellent'
-
low¶ >>> scale = ScaleFromList(['Bad', 'Medium', 'Good', 'Very good', 'Excellent']) >>> scale.low 'Bad'
-
lt(one: object, another: object) → bool[source]¶ >>> scale = ScaleFromList(['Bad', 'Medium', 'Good', 'Very good', 'Excellent']) >>> scale.lt('Medium', 'Excellent') True
-
max(iterable: Iterable[T_co]) → object[source]¶ Examples
>>> scale = ScaleFromList(['Bad', 'Medium', 'Good', 'Very good', 'Excellent']) >>> scale.max(['Good', 'Bad', 'Excellent']) 'Excellent'
-