summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-02-22 09:54:21 +0100
committerDaniel Friesel <derf@finalrewind.org>2018-02-22 09:54:21 +0100
commita5f79cd57a709bce08f365416e9aebd2fb9b481e (patch)
treed7c58a9f3b2680e875d8fab11194a5c312746206 /lib
parent65f787b00e597651c54230a9148fdb80952970fa (diff)
skip functions which failed to fit
Diffstat (limited to 'lib')
-rwxr-xr-xlib/dfatool.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/dfatool.py b/lib/dfatool.py
index d75653d..4a4435d 100755
--- a/lib/dfatool.py
+++ b/lib/dfatool.py
@@ -389,6 +389,7 @@ class AnalyticFunction:
self._model_str = function_str
rawfunction = function_str
self._dependson = [False] * (len(parameters) + num_args)
+ self.fit_success = False
for i in range(len(parameters)):
if rawfunction.find('parameter({})'.format(parameters[i])) >= 0:
@@ -437,8 +438,6 @@ class AnalyticFunction:
def fit(self, by_param, state_or_tran, model_attribute):
X, Y, num_valid, num_total = self._get_fit_data(by_param, state_or_tran, model_attribute)
- if state_or_tran == 'send':
- print('{} {} dependson {}'.format(state_or_tran, model_attribute, self._dependson))
if num_valid > 2:
error_function = lambda P, X, y: self._function(P, X) - y
try:
@@ -448,6 +447,7 @@ class AnalyticFunction:
return
if res.status > 0:
self._regression_args = res.x
+ self.fit_success = True
else:
print('[W] Fit failed for {}/{}: {} (function: {})'.format(state_or_tran, model_attribute, res.message, self._model_str))
else:
@@ -913,10 +913,11 @@ class EnergyModel:
if len(fit_results.keys()):
x = analytic.function_powerset(fit_results, self._parameter_names, num_args)
x.fit(self.by_param, state_or_tran, model_attribute)
- param_model[state_or_tran][model_attribute] = {
- 'fit_result': fit_results,
- 'function' : x
- }
+ if x.fit_success:
+ param_model[state_or_tran][model_attribute] = {
+ 'fit_result': fit_results,
+ 'function' : x
+ }
def model_getter(name, key, **kwargs):
if key in param_model[name]: