summaryrefslogtreecommitdiff
path: root/lib/paramfit.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2021-11-22 15:31:40 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2021-11-22 15:31:40 +0100
commit5b5380430eb3b701c1c43e18524a6b4759f46e27 (patch)
treea75cd1304c374354522a547e8fc667d3e094fc1a /lib/paramfit.py
parent5f79f5d018cad72b1c821dd962894d3483e29553 (diff)
handle fit errors in cross validation
Diffstat (limited to 'lib/paramfit.py')
-rw-r--r--lib/paramfit.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/paramfit.py b/lib/paramfit.py
index 8cfd486..9923e1a 100644
--- a/lib/paramfit.py
+++ b/lib/paramfit.py
@@ -202,9 +202,15 @@ def _try_fits(
if function_name not in raw_results:
raw_results[function_name] = dict()
error_function = param_function.error_function
- res = optimize.least_squares(
- error_function, [0, 1], args=(X, Y), xtol=2e-15
- )
+ try:
+ res = optimize.least_squares(
+ error_function, [0, 1], args=(X, Y), xtol=2e-15
+ )
+ except FloatingPointError as e:
+ logger.warning(
+ f"optimize.least_squares threw '{e}' when fitting {param_function} on {X}, {Y}"
+ )
+ continue
measures = regression_measures(param_function.eval(res.x, X), Y)
raw_results_by_param[other_parameters][function_name] = measures
for measure, error_rate in measures.items():