Skip to content

Commit

Permalink
ENH: error estimation defaults for small numbers (#741)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Günther committed Sep 24, 2024
1 parent 00cd2ab commit 171e47e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pygimli/frameworks/inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,10 @@ def run(self, dataVals, errorVals=None, **kwargs):
self.reset()
if errorVals is None: # use absoluteError and/or relativeError instead
absErr = kwargs.pop("absoluteError", 0)
relErr = kwargs.pop("relativeError",
0.01 if np.allclose(absErr, 0) else 0)
relErr = kwargs.pop("relativeError", 0)
if np.any(np.isclose(absErr + relErr, 0, atol=0)):
raise Exception("Zero error occurred, check abs/relErr")

errorVals = pg.abs(absErr / np.asarray(dataVals)) + relErr

if isinstance(errorVals, (float, int)):
Expand Down Expand Up @@ -1311,7 +1313,7 @@ def run(self, dataVals, errorVals=None, **kwargs):
if errorVals is None: # use absoluteError and/or relativeError instead
absErr = kwargs.pop("absoluteError", 0)
relErr = kwargs.pop("relativeError",
0.01 if np.allclose(absErr, 0) else 0)
0.01 if np.allclose(absErr, 0, atol=0) else 0)
errorVals = pg.abs(absErr / np.asarray(dataVals)) + relErr

if isinstance(errorVals, (float, int)):
Expand Down Expand Up @@ -1658,7 +1660,7 @@ def run(self, dataVals, errorVals=None, **kwargs):
if errorVals is None: # use absoluteError and/or relativeError instead
absErr = kwargs.pop("absoluteError", 0)
relErr = kwargs.pop("relativeError",
0.01 if np.allclose(absErr, 0) else 0)
0.01 if np.allclose(absErr, 0, atol=0) else 0)
errorVals = pg.abs(absErr / dataVals) + relErr

self.fop.regionManager().setConstraintType(0)
Expand Down

0 comments on commit 171e47e

Please sign in to comment.