Skip to content

Commit

Permalink
Refactored iteration through dataclass keys
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertDominguez committed Oct 24, 2024
1 parent 58d0fcc commit cf7e06f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions spotiflow/utils/fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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)
)
Expand Down

0 comments on commit cf7e06f

Please sign in to comment.