diff options
author | sheaf <sam.derbyshire@gmail.com> | 2021-12-02 15:01:53 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-12-03 10:12:42 -0500 |
commit | a9e035a430c7fdc228d56d21b27b3b8e815fd06b (patch) | |
tree | 90b83380fb01a20929b45fa191b1dca7fc615f3a | |
parent | 81082cf410fdcdbf10627f5334cc1dba1a9a2e06 (diff) | |
download | haskell-a9e035a430c7fdc228d56d21b27b3b8e815fd06b.tar.gz |
Test-suite: fix geometric mean of empty list
The geometric mean computation panicked when it was given
an empty list, which happens when there are no baselines.
Instead, we should simply return 1.
-rw-r--r-- | testsuite/driver/runtests.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/testsuite/driver/runtests.py b/testsuite/driver/runtests.py index 47d3324a82..bccd8ccc67 100644 --- a/testsuite/driver/runtests.py +++ b/testsuite/driver/runtests.py @@ -363,8 +363,11 @@ def cleanup_and_exit(exitcode): shutil.rmtree(tempdir, ignore_errors=True) exit(exitcode) -def geometric_mean(xs: List[float]) -> float: - return reduce(operator.mul, xs)**(1. / len(xs)) +def geometric_mean(xs): + if len(xs) > 0: + return reduce(operator.mul, xs)**(1. / len(xs)) + else: + return 1 def tabulate_metrics(metrics: List[PerfMetric]) -> None: abbrevLen = get_abbrev_hash_length() |