matrix.Matrix.rate_criterion

Matrix.rate_criterion(criterion: str, **choices_to_ratings)

Given a criterion, assign ratings (dictionary values) to given choices (dictionary keys).

Parameters

criterion (str) – The name of the criterion.

Keyword Arguments

**choices_to_ratings (float) – The choice-rating pairs.

Raises

ValueError – If the given criterion is not continuous.

Examples

>>> import matrix
>>> m = matrix.Matrix(
...     # choices=('apple', 'orange'),  # No need to add choices here!
...     criteria=('taste',),
...     weights=(7,)
... )
>>> m.rate_criterion('taste', apple=7, orange=9)
>>> m
|        |   taste | Percentage   |
|:-------|--------:|:-------------|
| Weight |       7 |              |
| apple  |       7 | 70.0         |
| orange |       9 | 90.0         |