summaryrefslogtreecommitdiff
path: root/lib/functions.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2021-03-22 16:47:21 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2021-03-22 16:47:21 +0100
commit9284ed037c001d8aa150adbeac533929b6e03a66 (patch)
treefdd0a1d6f0a593950b197e210f225b823d96b86d /lib/functions.py
parent7d3f011f0ce1a07ab9f041e6f73392fcd0e1585d (diff)
EnergyTraceWithLogicAnalyzer: Use ExternalTimerSync as well
DataProcessor is now deprecated and no longer in use
Diffstat (limited to 'lib/functions.py')
-rw-r--r--lib/functions.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/functions.py b/lib/functions.py
index 5c2e8ff..33ecaca 100644
--- a/lib/functions.py
+++ b/lib/functions.py
@@ -153,6 +153,21 @@ class NormalizationFunction:
class ModelFunction:
+ """
+ Encapsulates the behaviour of a single model attribute, e.g. TX power or write duration.
+
+ The behaviour may be constant or depend on a number of factors. Modelfunction is a virtual base class,
+ individuel decendents describe actual behaviour.
+
+ Common attributes:
+ :param value: median data value
+ :type value: float
+ :param value_error: static model value error
+ :type value_error: dict, optional
+ :param function_error: model error
+ :type value_error: dict, optional
+ """
+
def __init__(self, value):
# a model always has a static (median/mean) value. For StaticFunction, it's the only data point.
# For more complex models, it's usede both as fallback in case the model cannot predict the current
@@ -171,11 +186,13 @@ class ModelFunction:
raise NotImplementedError
def eval_mae(self, param_list):
+ """Return model Mean Absolute Error (MAE) for `param_list`."""
if self.is_predictable(param_list):
return self.function_error["mae"]
return self.value_error["mae"]
def to_json(self):
+ """Convert model to JSON."""
ret = {
"value": self.value,
"valueError": self.value_error,
@@ -185,6 +202,11 @@ class ModelFunction:
@classmethod
def from_json(cls, data):
+ """
+ Create ModelFunction instance from JSON.
+
+ Delegates to StaticFunction, SplitFunction, etc. as appropriate.
+ """
if data["type"] == "static":
mf = StaticFunction.from_json(data)
elif data["type"] == "split":