|
37 | 37 | ] |
38 | 38 |
|
39 | 39 |
|
| 40 | +class TestError(Exception): |
| 41 | + """Error with the tests provided.""" |
| 42 | + |
| 43 | + |
40 | 44 | def merge_obs_acc(obs, acc): |
41 | 45 | """ |
42 | 46 | Merge observation errors. |
@@ -409,17 +413,17 @@ def metric_colours(test, ref=None, var=None, obs=None, acc=None): |
409 | 413 | return colours |
410 | 414 |
|
411 | 415 |
|
412 | | -def normalise(test, ref, strict=True): |
| 416 | +def normalise(test, ref, same=False): |
413 | 417 | """ |
414 | 418 | Routine to normalise contents of test by contents of ref. |
415 | 419 |
|
416 | 420 | :param dict test: Dictionary of test metrics |
417 | 421 | :param dict ref: Dictionary of reference metrics |
418 | | - :param bool strict: if True then test and ref must have same metrics |
| 422 | + :param bool same: if True then test and ref must have same metrics |
419 | 423 | :returns: Dictionary of normalised test metrics |
420 | 424 | :rtype: dict. |
421 | 425 | """ |
422 | | - if strict: |
| 426 | + if same: |
423 | 427 | # Test to make sure reference metrics dictionary contains the same |
424 | 428 | # metrics as test metrics dictionary |
425 | 429 | assert sorted(test.keys()) == sorted(ref.keys()), ( |
@@ -651,10 +655,16 @@ def plot_nac( |
651 | 655 | plot_obs(ax, metrics, n_obs, color=OBS_GREY, zorder=2) |
652 | 656 |
|
653 | 657 | # Plot metric data |
| 658 | + # Check enough MARKERS for number of tests |
| 659 | + if len(tests) > len(MARKERS): |
| 660 | + raise TestError( |
| 661 | + f"Number of tests, {len(tests)}, is larger than available " |
| 662 | + f"plot MARKERS, {len(MARKERS)}." |
| 663 | + ) |
654 | 664 | n_tests = [] |
655 | | - for test, marker in zip(tests, MARKERS, strict=True): |
| 665 | + for test, marker in zip(tests, MARKERS[: len(tests)], strict=True): |
656 | 666 | # Normalise test by ref |
657 | | - n_test = normalise(test, ref, strict=True) |
| 667 | + n_test = normalise(test, ref, same=True) |
658 | 668 |
|
659 | 669 | # Check for green/amber/red/grey |
660 | 670 | colours = metric_colours(n_test, var=n_var, obs=n_obs, acc=n_acc) |
|
0 commit comments