summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-02-06 08:52:30 +0100
committerDaniel Friesel <derf@finalrewind.org>2018-02-06 08:52:30 +0100
commitf0c6496c821a618a9f6bc442c0f6c72f03b54ec8 (patch)
treecc5a9c34bc8bb6566d25ba72f4b1bf3e2fc66452 /lib
parent466895124cbf4bd1eb1b8a61ab641904db258501 (diff)
simplify model generation
Diffstat (limited to 'lib')
-rwxr-xr-xlib/dfatool.py24
1 files changed, 2 insertions, 22 deletions
diff --git a/lib/dfatool.py b/lib/dfatool.py
index 7a5830b..470c52e 100755
--- a/lib/dfatool.py
+++ b/lib/dfatool.py
@@ -470,17 +470,7 @@ class EnergyModel:
return static_median_getter
def get_static_using_mean(self):
- static_model = {}
- for name, elem in self.by_name.items():
- static_model[name] = {}
- for key in ['power', 'energy', 'duration', 'timeout', 'rel_energy_prev', 'rel_energy_next']:
- if key in elem:
- try:
- static_model[name][key] = np.mean(elem[key])
- except RuntimeWarning:
- print('[W] Got no data for {} {}'.format(name, key))
- except FloatingPointError as fpe:
- print('[W] Got no data for {} {}: {}'.format(name, key, fpe))
+ static_model = self._get_model_from_dict(self.by_name, np.mean)
def static_mean_getter(name, key, **kwargs):
return static_model[name][key]
@@ -488,17 +478,7 @@ class EnergyModel:
return static_mean_getter
def get_param_lut(self):
- lut_model = {}
- for name, elem in self.by_param.items():
- lut_model[name] = {}
- for key in ['power', 'energy', 'duration', 'timeout', 'rel_energy_prev', 'rel_energy_next']:
- if key in elem:
- try:
- lut_model[name][key] = np.mean(elem[key])
- except RuntimeWarning:
- print('[W] Got no data for {} {}'.format(name, key))
- except FloatingPointError as fpe:
- print('[W] Got no data for {} {}: {}'.format(name, key, fpe))
+ lut_model = self._get_model_from_dict(self.by_param, np.median)
def lut_median_getter(name, key, param, **kwargs):
return lut_model[(name, tuple(param))][key]