Skip to content
Snippets Groups Projects
Commit a9e035a4 authored by sheaf's avatar sheaf Committed by Marge Bot
Browse files

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.
parent 81082cf4
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment