From 6ecc4a4126a17b0e4897f2e606783673e82a9e77 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Tue, 19 Sep 2023 12:34:44 +0200 Subject: [PATCH] make final fit parameter values --- src/nmreval/fit/parameter.py | 5 ++++- src/nmreval/fit/result.py | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/nmreval/fit/parameter.py b/src/nmreval/fit/parameter.py index 502f35f..3c24851 100644 --- a/src/nmreval/fit/parameter.py +++ b/src/nmreval/fit/parameter.py @@ -186,7 +186,6 @@ class Parameter: @property def value(self) -> float | None: - # TODO first _value, then _expr if self._value is not None: return self._value @@ -239,3 +238,7 @@ class Parameter: return para_copy + def fix(self): + self._value = self.value + self.namespace = {} + diff --git a/src/nmreval/fit/result.py b/src/nmreval/fit/result.py index d825e14..82f7531 100644 --- a/src/nmreval/fit/result.py +++ b/src/nmreval/fit/result.py @@ -187,7 +187,7 @@ class FitResult(Points): nice_name = m.group(1) if func_number in split_funcs: nice_func = split_funcs[func_number] - + pvalue.fix() pvalue.name = nice_name pvalue.function = nice_func parameter_dic[pname] = pvalue @@ -196,6 +196,8 @@ class FitResult(Points): if modelname[0] == '(' and modelname[-1] == ')': modelname = modelname[1:-1] + print(parameter_dic) + return parameter_dic, modelname @property @@ -233,9 +235,9 @@ class FitResult(Points): s.write(self.parameter_string()) if statistics: - s.write('Statistics\n') + s.write('\nStatistics\n') for k, v in self.statistics.items(): - s.write(f' {k} : {v:.4f}') + s.write(f' {k} : {v:.4f}\n') if correlations and self.correlation is not None: s.write('\nCorrelation (partial corr.)\n')