summaryrefslogtreecommitdiff
path: root/lib/functions.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/functions.py
parentd3904f66981cf9bdd8962e8e32fcc11497cd2628 (diff)
documentation
Diffstat (limited to 'lib/functions.py')
-rw-r--r--lib/functions.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/functions.py b/lib/functions.py
index 9c58b58..76be562 100644
--- a/lib/functions.py
+++ b/lib/functions.py
@@ -14,11 +14,11 @@ arg_support_enabled = True
def powerset(iterable):
"""
- Calculate powerset of given items.
+ Calculate powerset of `iterable` elements.
Returns an iterable containing one tuple for each powerset element.
- Example: powerset([1, 2]) -> [(), (1), (2), (1, 2)]
+ Example: `powerset([1, 2])` -> `[(), (1), (2), (1, 2)]`
"""
s = list(iterable)
return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))
@@ -86,14 +86,24 @@ class ParamFunction:
class NormalizationFunction:
"""
- Hi
+ Wrapper for parameter normalization functions used in YAML PTA/DFA models.
"""
def __init__(self, function_str):
+ """
+ Create a new normalization function from `function_str`.
+
+ :param function_str: Function string. Signature: (param) -> float
+ """
self._function_str = function_str
self._function = eval('lambda param: ' + function_str)
def eval(self, param_value):
+ """
+ Evaluate the normalization function and return its output.
+
+ :param param_value: Parameter value
+ """
return self._function(param_value)
class AnalyticFunction: