Skip to content

Commit cfbad45

Browse files
committed
Make suiet2p compatible with py3.12
1 parent c88e1ba commit cfbad45

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

suite2p/detection/stats.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def median_pix(ypix, xpix):
2626
ymed = ypix[imin]
2727
return [ymed, xmed]
2828

29-
3029
class EllipseData(NamedTuple):
3130
mu: float
3231
cov: float
@@ -47,17 +46,19 @@ def radius(self) -> float:
4746
def aspect_ratio(self) -> float:
4847
ry, rx = self.radii
4948
return aspect_ratio(width=ry, height=rx)
50-
49+
50+
def default_rsort():
51+
return np.sort(distance_kernel(radius=30).flatten())
5152

5253
@dataclass(frozen=True)
5354
class ROI:
55+
# To avoid the ValueError caused by using a mutable default value in your dataclass, you should use the default_factory argument of the field function.
5456
ypix: np.ndarray
5557
xpix: np.ndarray
5658
lam: np.ndarray
5759
med: np.ndarray
5860
do_crop: bool
59-
rsort: np.ndarray = field(default=np.sort(distance_kernel(radius=30).flatten()),
60-
repr=False)
61+
rsort: np.ndarray = field(default_factory=default_rsort, repr=False)
6162

6263
def __post_init__(self):
6364
"""Validate inputs."""

0 commit comments

Comments
 (0)