From cf7e06f2e727f25ea468c536c0d3702837098b3d Mon Sep 17 00:00:00 2001 From: Albert Dominguez Mantes <31998088+AlbertDominguez@users.noreply.github.com> Date: Thu, 24 Oct 2024 12:06:26 +0200 Subject: [PATCH] Refactored iteration through dataclass keys --- spotiflow/utils/fitting.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spotiflow/utils/fitting.py b/spotiflow/utils/fitting.py index 507d4eb..6d5a48c 100644 --- a/spotiflow/utils/fitting.py +++ b/spotiflow/utils/fitting.py @@ -8,7 +8,7 @@ from scipy.optimize import curve_fit from tqdm.auto import tqdm -from dataclasses import dataclass +from dataclasses import dataclass, fields FWHM_CONSTANT = 2 * np.sqrt(2 * np.log(2)) @@ -257,12 +257,12 @@ def estimate_params( ) if img.ndim == 2: - keys = FitParams2D.__dataclass_fields__.keys() + keys = tuple(f.name for f in fields(FitParams2D)) params = FitParams2D( **dict((k, np.array([getattr(p, k) for p in params])) for k in keys) ) elif img.ndim == 3: - keys = FitParams3D.__dataclass_fields__.keys() + keys = tuple(f.name for f in fields(FitParams3D)) params = FitParams3D( **dict((k, np.array([getattr(p, k) for p in params])) for k in keys) )