|
11 | 11 | Any, |
12 | 12 | Callable, |
13 | 13 | Mapping, |
| 14 | + MutableMapping, |
| 15 | + MutableSequence, |
14 | 16 | Optional, |
15 | 17 | Sequence, |
16 | 18 | Tuple, |
| 19 | + Union, |
17 | 20 | ) |
18 | 21 |
|
19 | 22 | import logging |
@@ -222,11 +225,11 @@ def cluster_tools(tools_dict: "Mapping[str,Sequence[float]]", better: "Optional[ |
222 | 225 | distances = [] |
223 | 226 | dimcorr = None |
224 | 227 | if dims == 1: |
225 | | - if better.endswith("right") or better.endswith("maximize"): |
| 228 | + if better is not None and (better.endswith("right") or better.endswith("maximize")): |
226 | 229 | dimcorr = None |
227 | 230 | else: |
228 | 231 | dimcorr = [ True ] |
229 | | - elif dims == 2: |
| 232 | + elif dims == 2 and better is not None: |
230 | 233 | if better == "top-right": |
231 | 234 | dimcorr = None |
232 | 235 | elif better == "bottom-right": |
@@ -341,18 +344,21 @@ def build_table(challenges: "Sequence[Mapping[str, Any]]", classificator_id: "Op |
341 | 344 | if len(challenge["aggregation_test_actions"]) > 0: |
342 | 345 | # First, let's dig in the assessment metrics to |
343 | 346 | # build a map from metrics label to metrics entry |
344 | | - metrics_by_label = dict() |
| 347 | + metrics_by_label: "MutableMapping[str, MutableSequence[Mapping[str, Any]]]" = dict() |
345 | 348 | for m_cat in metrics_categories: |
346 | 349 | if m_cat['category'] == 'assessment': |
347 | 350 | for m_pair in m_cat["metrics"]: |
348 | 351 | # Now, the entry |
349 | 352 | the_metrics = metrics[m_pair["metrics_id"]] |
350 | 353 | metrics_metadata = the_metrics.get("_metadata") |
351 | | - metrics_labels = [] |
| 354 | + metrics_labels: "MutableSequence[str]" = [] |
352 | 355 | # Metrics labels, ordered by precedence |
353 | 356 | if metrics_metadata is not None: |
354 | | - metrics_label = metrics_metadata.get("level_2:metric_id") |
355 | | - metrics_labels.append(metrics_label) |
| 357 | + metrics_label_m: "Optional[Union[str, Sequence[str]]]" = metrics_metadata.get("level_2:metric_id") |
| 358 | + if isinstance(metrics_label_m, list): |
| 359 | + metrics_labels.extend(metrics_label_m) |
| 360 | + elif isinstance(metrics_label_m, str): |
| 361 | + metrics_labels.append(metrics_label_m) |
356 | 362 |
|
357 | 363 | _ , metrics_label = the_metrics["orig_id"].split(":" , 1) |
358 | 364 | if metrics_label is not None: |
|
0 commit comments