1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
From: Matthew Newville <newville@cars.uchicago.edu>
Subject: capture and ignore std_dev=0 warnings from uncertainties package
Origin: https://github.com/lmfit/lmfit-py/commit/a2830038ae769e2eff39bbb7f8a168dbfade2f34
Origin: https://github.com/lmfit/lmfit-py/commit/045a58ea75527d5c3575db469a965621b5a6971e
Bug-Debian: https://bugs.debian.org/1106426
--- a/lmfit/parameter.py
+++ b/lmfit/parameter.py
@@ -2,6 +2,7 @@
from copy import deepcopy
import json
+import warnings
from asteval import Interpreter, get_ast_names, valid_symbol_name
from numpy import arcsin, array, cos, inf, isclose, sin, sqrt
@@ -572,8 +573,13 @@
par.stderr = sqrt(covar[vindex, vindex])
stderr = getattr(par, 'stderr', 0.0)
if stderr is None:
- stderr = 0.0
- uvars[par.name] = ufloat(par.value, stderr)
+ stderr = 0.00
+ if stderr < tiny*max(tiny, abs(par.value)):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore")
+ uvars[par.name] = ufloat(par.value, stderr)
+ else:
+ uvars[par.name] = ufloat(par.value, stderr)
corr_uvars = None
if covar is not None:
|