From c9cef8ff5f5b2da39807a761ecf8b30c9964a09f Mon Sep 17 00:00:00 2001 From: Justus Kuhlmann Date: Tue, 4 Nov 2025 09:04:39 +0000 Subject: [PATCH] add some typecasts --- pyerrors/fits.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pyerrors/fits.py b/pyerrors/fits.py index a33c8091..00a9510d 100644 --- a/pyerrors/fits.py +++ b/pyerrors/fits.py @@ -776,7 +776,7 @@ def fit_lin(x: Sequence[Union[Obs, int, float]], y: Sequence[Obs], **kwargs) -> Returns ------- fit_parameters : list[Obs] - LIist of fitted observables. + List of fitted observables. """ def f(a, x): @@ -879,7 +879,10 @@ def error_band(x: list[int], func: Callable, beta: Union[Fit_result, list[Obs]]) err : np.array(Obs) Error band for an array of sample values x """ - cov = covariance(beta) + if isinstance(beta, Fit_result): + cov = covariance(np.array(beta.fit_parameters)) + else: + cov = covariance(beta) if np.any(np.abs(cov - cov.T) > 1000 * np.finfo(np.float64).eps): warnings.warn("Covariance matrix is not symmetric within floating point precision", RuntimeWarning) @@ -890,9 +893,9 @@ def error_band(x: list[int], func: Callable, beta: Union[Fit_result, list[Obs]]) err = [] for i, item in enumerate(x): err.append(np.sqrt(deriv[i] @ cov @ deriv[i])) - err = np.array(err) + err_array = np.array(err) - return err + return err_array def ks_test(objects: Optional[list[Fit_result]]=None): @@ -916,7 +919,7 @@ def ks_test(objects: Optional[list[Fit_result]]=None): else: obs_list = objects - p_values = [o.p_value for o in obs_list] + p_values = np.asarray([o.p_value for o in obs_list]) bins = len(p_values) x = np.arange(0, 1.001, 0.001) @@ -928,7 +931,7 @@ def ks_test(objects: Optional[list[Fit_result]]=None): plt.title(str(bins) + ' p-values') n = np.arange(1, bins + 1) / np.float64(bins) - Xs = np.sort(p_values) + Xs: ndarray[float] = np.sort(p_values) plt.step(Xs, n) diffs = n - Xs loc_max_diff = np.argmax(np.abs(diffs))