|
2 | 2 | """Classes to support data fitting.""" |
3 | 3 |
|
4 | 4 | from copy import deepcopy as copy |
| 5 | +from dataclasses import dataclass, field |
5 | 6 | from inspect import getfullargspec, isclass |
| 7 | +from typing import Union, Optional |
6 | 8 |
|
7 | 9 | import lmfit as lmfit_mod |
8 | 10 | import numpy as np |
@@ -165,7 +167,7 @@ def wrapper(beta, x, y, sigma, *args): |
165 | 167 | self.minimize_func = wrapper |
166 | 168 |
|
167 | 169 |
|
168 | | -class _curve_fit_result: |
| 170 | +class _Curve_Fit_Result: |
169 | 171 | """Represent a result from fitting using :py:func:`scipy.optimize.curve_fit` |
170 | 172 | as a class to make handling easier. |
171 | 173 | """ |
@@ -203,6 +205,7 @@ def __init__(self, popt=None, pcov=None, infodict=None, mesg=None, ier=None): |
203 | 205 | self._residual_vals = None |
204 | 206 | self.chisq = None |
205 | 207 | self.nfree = None |
| 208 | + self.f_name = None |
206 | 209 | self._infodict = infodict |
207 | 210 | if infodict: |
208 | 211 | for k in infodict: |
@@ -377,6 +380,22 @@ def add_metadata(self, datafile): |
377 | 380 | return datafile |
378 | 381 |
|
379 | 382 |
|
| 383 | +@dataclass |
| 384 | +class _Curve_Fit_Output: |
| 385 | + """Dataclass for gathering together information about the output from a curve fitting operation.""" |
| 386 | + |
| 387 | + prefix: str = "" |
| 388 | + columns: AttributeStore = field(default_factory=dict) |
| 389 | + result: Union[bool, str, None] = None |
| 390 | + replace: bool = False |
| 391 | + header: Optional[str] = None |
| 392 | + residuals: bool = False |
| 393 | + asrow: bool = False |
| 394 | + output: str = "row" |
| 395 | + scale_covar: bool = True |
| 396 | + nan_policy: str = "raise" |
| 397 | + |
| 398 | + |
380 | 399 | def _prep_lmfit_model(model, kargs): |
381 | 400 | """Prepare an lmfit model instance. |
382 | 401 |
|
|
0 commit comments