summaryrefslogtreecommitdiff
path: root/lib/dfatool.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-08-16 14:26:11 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2019-08-16 14:26:11 +0200
commit98330afce6f6b7173f89005f8c6e574c7821175d (patch)
tree4b015b3cec75bd017c053877c58e90216b3834bb /lib/dfatool.py
parentd3904f66981cf9bdd8962e8e32fcc11497cd2628 (diff)
documentation
Diffstat (limited to 'lib/dfatool.py')
-rwxr-xr-xlib/dfatool.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/dfatool.py b/lib/dfatool.py
index 95e76e7..abf8c10 100755
--- a/lib/dfatool.py
+++ b/lib/dfatool.py
@@ -21,11 +21,10 @@ arg_support_enabled = True
def running_mean(x: np.ndarray, N: int) -> np.ndarray:
"""
- Compute running average.
+ Compute `N` elements wide running average over `x`.
- arguments:
- x -- NumPy array
- N -- how many items to average
+ :param x: 1-Dimensional NumPy array
+ :param N: how many items to average
"""
cumsum = np.cumsum(np.insert(x, 0, 0))
return (cumsum[N:] - cumsum[:-N]) / N
@@ -71,16 +70,17 @@ def gplearn_to_function(function_str: str):
print(eval_str)
return eval(eval_str, eval_globals)
-def _arg_name(arg_index: int) -> str:
- return '~arg{:02}'.format(arg_index)
-
def append_if_set(aggregate: dict, data: dict, key: str):
"""Append data[key] to aggregate if key in data."""
if key in data:
aggregate.append(data[key])
def mean_or_none(arr):
- """Compute mean of NumPy array arr, return -1 if empty."""
+ """
+ Compute mean of NumPy array `arr`, return -1 if empty.
+
+ :param arr: 1-Dimensional NumPy array
+ """
if len(arr):
return np.mean(arr)
return -1