Skip to content

Commit 98aaa31

Browse files
committed
add improved type hint to fit dict
1 parent f6445c8 commit 98aaa31

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

src/cvsim/fit_curve.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def _fit_var_checker(fit_vars: dict, fit_default_vars: dict) -> dict:
175175
def _scheme(self, get_var: Callable[[str], float]) -> CyclicVoltammetryScheme:
176176
raise NotImplementedError
177177

178-
def _fit(self, fit_vars: dict[str, _ParamGuess]) -> tuple[np.ndarray, np.ndarray, dict]:
178+
def _fit(self, fit_vars: dict[str, _ParamGuess]) -> tuple[np.ndarray, np.ndarray, dict[str, float]]:
179179
fit_vars = self._non_none_dict(fit_vars)
180180
fixed_vars = self._non_none_dict(self.fixed_vars)
181181

@@ -246,7 +246,7 @@ def fit_function(
246246
current_fit = fit_function(self.voltage, *popt)
247247
sigma = np.sqrt(np.diag(pcov)) # one standard deviation of the parameters
248248

249-
final_fit = {}
249+
final_fit: dict[str, float] = {}
250250
for val, error, param in zip(popt, sigma, fitting_params):
251251
final_fit[param] = val
252252
print(f"Final fit: '{param}': {val:.2E} +/- {error:.0E}")
@@ -280,7 +280,7 @@ def fit(
280280
reduction_potential: _ParamGuess = None,
281281
diffusion_reactant: _ParamGuess = None,
282282
diffusion_product: _ParamGuess = None,
283-
) -> tuple[np.ndarray, np.ndarray, dict]:
283+
) -> tuple[np.ndarray, np.ndarray, dict[str, float]]:
284284
"""
285285
Fits the CV for a reversible (Nernstian) one-electron transfer mechanism.
286286
If a parameter is given, it must be a: float for initial guess of parameter; tuple[float, float] for
@@ -305,7 +305,7 @@ def fit(
305305
Array of potential (V) values of the CV fit.
306306
current_fit : np.ndarray
307307
Array of current (A) values of the CV fit.
308-
final_fit : dict
308+
final_fit : dict[str, float]
309309
Dictionary of final fitting parameter values of the CV fit.
310310
311311
"""
@@ -424,7 +424,7 @@ def fit(
424424
diffusion_product: _ParamGuess = None,
425425
alpha: _ParamGuess = None,
426426
k0: _ParamGuess = None,
427-
) -> tuple[np.ndarray, np.ndarray, dict]:
427+
) -> tuple[np.ndarray, np.ndarray, dict[str, float]]:
428428
"""
429429
Fits the CV for a quasi-reversible one-electron transfer mechanism.
430430
If a parameter is given, it must be a: float for initial guess of parameter; tuple[float, float] for
@@ -455,7 +455,7 @@ def fit(
455455
Array of potential (V) values of the CV fit.
456456
current_fit : np.ndarray
457457
Array of current (A) values of the CV fit.
458-
final_fit : dict
458+
final_fit : dict[str, float]
459459
Dictionary of final fitting parameter values of the CV fit.
460460
461461
"""
@@ -596,7 +596,7 @@ def fit(
596596
k0: _ParamGuess = None,
597597
k_forward: _ParamGuess = None,
598598
k_backward: _ParamGuess = None,
599-
) -> tuple[np.ndarray, np.ndarray, dict]:
599+
) -> tuple[np.ndarray, np.ndarray, dict[str, float]]:
600600
"""
601601
Fits the CV for a quasi-reversible one-electron transfer, followed by a reversible first
602602
order homogeneous chemical transformation mechanism.
@@ -634,7 +634,7 @@ def fit(
634634
Array of potential (V) values of the CV fit.
635635
current_fit : np.ndarray
636636
Array of current (A) values of the CV fit.
637-
final_fit : dict
637+
final_fit : dict[str, float]
638638
Dictionary of final fitting parameter values of the CV fit.
639639
640640
"""
@@ -799,7 +799,7 @@ def fit(
799799
alpha2: _ParamGuess = None,
800800
k0: _ParamGuess = None,
801801
k0_2: _ParamGuess = None,
802-
) -> tuple[np.ndarray, np.ndarray, dict]:
802+
) -> tuple[np.ndarray, np.ndarray, dict[str, float]]:
803803
"""
804804
Fits the CV for a two successive one-electron quasi-reversible transfer mechanism.
805805
If a parameter is given, it must be a: float for initial guess of parameter; tuple[float, float] for
@@ -842,7 +842,7 @@ def fit(
842842
Array of potential (V) values of the CV fit.
843843
current_fit : np.ndarray
844844
Array of current (A) values of the CV fit.
845-
final_fit : dict
845+
final_fit : dict[str, float]
846846
Dictionary of final fitting parameter values of the CV fit.
847847
848848
"""
@@ -1042,7 +1042,7 @@ def fit(
10421042
k_backward: _ParamGuess = None,
10431043
k_forward2: _ParamGuess = None,
10441044
k_backward2: _ParamGuess = None,
1045-
) -> tuple[np.ndarray, np.ndarray, dict]:
1045+
) -> tuple[np.ndarray, np.ndarray, dict[str, float]]:
10461046
"""
10471047
Fits the CV for a Square Scheme mechanism.
10481048
If a parameter is given, it must be a: float for initial guess of parameter; tuple[float, float] for
@@ -1094,7 +1094,7 @@ def fit(
10941094
Array of potential (V) values of the CV fit.
10951095
current_fit : np.ndarray
10961096
Array of current (A) values of the CV fit.
1097-
final_fit : dict
1097+
final_fit : dict[str, float]
10981098
Dictionary of final fitting parameter values of the CV fit.
10991099
11001100
"""

0 commit comments

Comments
 (0)