make using relative diff optional for now

This commit is contained in:
Valentin Boettcher 2022-08-15 10:14:41 +02:00
parent 404d51d295
commit 52d642c957
No known key found for this signature in database
GPG key ID: E034E12B7AF56ACE
2 changed files with 13 additions and 1 deletions

7
stocproc/config.py Normal file
View file

@ -0,0 +1,7 @@
import configparser
config = configparser.ConfigParser()
config.read("stocproc.ini")
USE_NORMALIZED_DIFF = config["FFT"].getboolean("use_normalized_diff", fallback=False)

View file

@ -24,6 +24,7 @@ import warnings
MAX_FLOAT = sys.float_info.max
log = logging.getLogger(__name__)
from .config import USE_NORMALIZED_DIFF
class FTReferenceError(Exception):
pass
@ -330,7 +331,11 @@ def _relDiff(xRef, x, norm=1):
def _absDiff(xRef, x, norm=1):
return np.max(np.abs(xRef - x)) / norm
diff = np.max(np.abs(xRef - x))
if USE_NORMALIZED_DIFF:
return diff / norm
else:
return diff
def _f_opt_for_SLSQP_minimizer(