|
20 | 20 |
|
21 | 21 | import logging |
22 | 22 | from dataclasses import dataclass, field |
23 | | -from typing import List, Optional, Set, Union |
| 23 | +from typing import List, Optional, Sequence, Set, Union |
24 | 24 |
|
25 | 25 | import numpy as np |
26 | 26 | import pandas as pd |
@@ -153,11 +153,12 @@ def display(self) -> str: |
153 | 153 | for crit in sorted(active, key=lambda c: -total_weights[c.name]): |
154 | 154 | total = total_weights[crit.name] |
155 | 155 | effective = total / total_sum if total_sum > 0 else 0.0 |
156 | | - bar = _weight_bar(effective, width=len(active)) |
| 156 | + bar = _weight_bar(effective, width=len(active) * 2) |
157 | 157 | lines.append( |
158 | | - f" {crit.name:<{max_len+4}} {bar} " |
| 158 | + f" {crit.name:<{max_len+4}} " |
159 | 159 | f"base={crit.weight:.5f} total={total_weights[crit.name]:.5f} " |
160 | | - f"effective={effective:.5f}" |
| 160 | + f"effective={effective:.5f} " |
| 161 | + f"{bar}" |
161 | 162 | ) |
162 | 163 |
|
163 | 164 | lines.append("") |
@@ -336,34 +337,6 @@ def _check_consistency(criteria): |
336 | 337 | if not all([criteria[0].space is criterion.space for criterion in criteria]): |
337 | 338 | raise ValueError("Criteria must share the same space of categories.") |
338 | 339 |
|
339 | | - def criteria_total_weights( |
340 | | - self, |
341 | | - categories_influence: float = 0.5, |
342 | | - base_weight_influence: float = 0.5, |
343 | | - active_only: bool = True, |
344 | | - ) -> dict[str, float]: |
345 | | - """Compute weighted combination of base weight and category-derived weight. |
346 | | -
|
347 | | - Parameters |
348 | | - ---------- |
349 | | - categories_influence : float |
350 | | - Weight given to category-derived score. Must sum to 1 with |
351 | | - ``base_weight_influence``. |
352 | | - base_weight_influence : float |
353 | | - Weight given to the criterion's base weight. |
354 | | - active_only : bool |
355 | | - If True (default), only criteria with non-zero total weight are returned. |
356 | | -
|
357 | | - Returns |
358 | | - ------- |
359 | | - dict[str, float] |
360 | | - Mapping of criterion name to total weight. |
361 | | - """ |
362 | | - if categories_influence + base_weight_influence != 1.0: |
363 | | - raise ValueError( |
364 | | - "categories_influence and base_weight_influence must sum to 1." |
365 | | - ) |
366 | | - |
367 | 340 | def criteria_total_weights( |
368 | 341 | self, |
369 | 342 | categories_influence: float = 0.5, |
|
0 commit comments