From 3a02d19162975b619ea11259ce763c1902837b81 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 8 Oct 2019 08:22:03 +0200 Subject: dfatool: refactor get_static --- lib/dfatool.py | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-) mode change 100755 => 100644 lib/dfatool.py (limited to 'lib/dfatool.py') diff --git a/lib/dfatool.py b/lib/dfatool.py old mode 100755 new mode 100644 index cc07026..8b0ff09 --- a/lib/dfatool.py +++ b/lib/dfatool.py @@ -1206,31 +1206,23 @@ class AnalyticModel: return self.parameters[param_index] return str(param_index) - def get_static(self): + def get_static(self, use_mean=False): """ Get static model function: name, attribute -> model value. Uses the median of by_name for modeling. """ - static_model = self._get_model_from_dict(self.by_name, np.median) - - def static_median_getter(name, key, **kwargs): - return static_model[name][key] + getter_function = np.median - return static_median_getter + if use_mean: + getter_function = np.mean - def get_static_using_mean(self): - """ - Get static model function: name, attribute -> model value. - - Uses the mean of by_name for modeling. - """ - static_model = self._get_model_from_dict(self.by_name, np.mean) + static_model = self._get_model_from_dict(self.by_name, getter_function) - def static_mean_getter(name, key, **kwargs): + def static_model_getter(name, key, **kwargs): return static_model[name][key] - return static_mean_getter + return static_model_getter def get_param_lut(self, fallback = False): """ @@ -1561,31 +1553,23 @@ class PTAModel: vprint(self.verbose, '[W] Got no data for {} {}: {}'.format(name, key, fpe)) return model - def get_static(self): + def get_static(self, use_mean=False): """ Get static model function: name, attribute -> model value. Uses the median of by_name for modeling. """ - static_model = self._get_model_from_dict(self.by_name, np.median) - - def static_median_getter(name, key, **kwargs): - return static_model[name][key] + getter_function = np.median - return static_median_getter + if use_mean: + getter_function = np.mean - def get_static_using_mean(self): - """ - Get static model function: name, attribute -> model value. - - Uses the mean of by_name for modeling. - """ - static_model = self._get_model_from_dict(self.by_name, np.mean) + static_model = self._get_model_from_dict(self.by_name, getter_function) - def static_mean_getter(name, key, **kwargs): + def static_model_getter(name, key, **kwargs): return static_model[name][key] - return static_mean_getter + return static_model_getter def get_param_lut(self, fallback = False): """ -- cgit v1.2.3