Skip to content

Commit 8223a97

Browse files
committed
Attempt to fix change in allowed dataclass hints
1 parent 9eea737 commit 8223a97

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

wirecell/util/peaks.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
from scipy import ndimage
1414
from math import sqrt, pi
1515

16+
try:
17+
from numpy.typing import ArrayLike
18+
except ImportError:
19+
ArrayLike = np.ndarray[int, np.dtype[float]]
20+
1621
from wirecell.util.codec import dataclass_dictify
1722
from wirecell.util.bbox import union as union_bbox
1823

@@ -83,7 +88,7 @@ class BaselineNoise:
8388
34% quantile above the median
8489
'''
8590

86-
cov : numpy.ndarray | None = None
91+
cov: ArrayLike | None = dataclasses.field(default_factory=lambda: None)
8792
'''
8893
Covariance matrix of fit. Non implies A,mu,sigma are statistical.
8994
'''
@@ -172,7 +177,7 @@ class Peak1d:
172177
sigma: float = 0.0
173178
'''The fit Gaussian sigma fit parameter. See gauss().'''
174179

175-
cov: numpy.ndarray = numpy.zeros((0,))
180+
cov: ArrayLike | None = dataclasses.field(default_factory=lambda: None)
176181
'''The covariance matrix of the fit.'''
177182

178183

@@ -255,17 +260,17 @@ def indices(self):
255260
Bounding boxes of each object.
256261
'''
257262

258-
sums: numpy.ndarray = numpy.zeros((0,))
263+
sums: ArrayLike = dataclasses.field(default_factory=lambda: numpy.zeros((0,)))
259264
'''
260265
The total value of each object.
261266
'''
262267

263-
counts: numpy.ndarray = numpy.zeros((0,))
268+
counts: ArrayLike = dataclasses.field(default_factory=lambda: numpy.zeros((0,)))
264269
'''
265270
The number of pixels of each object.
266271
'''
267272

268-
coms: numpy.ndarray = numpy.zeros((0,0))
273+
coms: ArrayLike = dataclasses.field(default_factory=lambda: numpy.zeros((0,0)))
269274
'''
270275
The center of mass of objects in pixel space.
271276
'''

0 commit comments

Comments
 (0)