Skip to content

Commit

Permalink
Update statistics.py
Browse files Browse the repository at this point in the history
  • Loading branch information
uduse authored and ChrisCummins committed Feb 17, 2022
1 parent 2123184 commit 8a7819f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions compiler_gym/util/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import numpy as np


def geometric_mean(iterable):
def geometric_mean(array_like):
"""Zero-length-safe geometric mean."""
values = np.asarray(iterable)
values = np.asarray(array_like)
if not values.size:
return 0
# Shortcut to return 0 when any element of the input is not positive.
Expand All @@ -17,17 +17,17 @@ def geometric_mean(iterable):
return np.exp(a.sum() / len(a))


def arithmetic_mean(iterable):
def arithmetic_mean(array_like):
"""Zero-length-safe arithmetic mean."""
values = np.asarray(iterable)
values = np.asarray(array_like)
if not values.size:
return 0
return values.mean()


def stdev(iterable):
def stdev(array_like):
"""Zero-length-safe standard deviation."""
values = np.asarray(iterable)
values = np.asarray(array_like)
if not values.size:
return 0
return values.std()

0 comments on commit 8a7819f

Please sign in to comment.