From f0c6496c821a618a9f6bc442c0f6c72f03b54ec8 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 6 Feb 2018 08:52:30 +0100 Subject: simplify model generation --- lib/dfatool.py | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) (limited to 'lib') 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] -- cgit v1.2.3