|
13 | 13 | from scipy import ndimage |
14 | 14 | from math import sqrt, pi |
15 | 15 |
|
| 16 | +try: |
| 17 | + from numpy.typing import ArrayLike |
| 18 | +except ImportError: |
| 19 | + ArrayLike = np.ndarray[int, np.dtype[float]] |
| 20 | + |
16 | 21 | from wirecell.util.codec import dataclass_dictify |
17 | 22 | from wirecell.util.bbox import union as union_bbox |
18 | 23 |
|
@@ -83,7 +88,7 @@ class BaselineNoise: |
83 | 88 | 34% quantile above the median |
84 | 89 | ''' |
85 | 90 |
|
86 | | - cov : numpy.ndarray | None = None |
| 91 | + cov: ArrayLike | None = dataclasses.field(default_factory=lambda: None) |
87 | 92 | ''' |
88 | 93 | Covariance matrix of fit. Non implies A,mu,sigma are statistical. |
89 | 94 | ''' |
@@ -172,7 +177,7 @@ class Peak1d: |
172 | 177 | sigma: float = 0.0 |
173 | 178 | '''The fit Gaussian sigma fit parameter. See gauss().''' |
174 | 179 |
|
175 | | - cov: numpy.ndarray = numpy.zeros((0,)) |
| 180 | + cov: ArrayLike | None = dataclasses.field(default_factory=lambda: None) |
176 | 181 | '''The covariance matrix of the fit.''' |
177 | 182 |
|
178 | 183 |
|
@@ -255,17 +260,17 @@ def indices(self): |
255 | 260 | Bounding boxes of each object. |
256 | 261 | ''' |
257 | 262 |
|
258 | | - sums: numpy.ndarray = numpy.zeros((0,)) |
| 263 | + sums: ArrayLike = dataclasses.field(default_factory=lambda: numpy.zeros((0,))) |
259 | 264 | ''' |
260 | 265 | The total value of each object. |
261 | 266 | ''' |
262 | 267 |
|
263 | | - counts: numpy.ndarray = numpy.zeros((0,)) |
| 268 | + counts: ArrayLike = dataclasses.field(default_factory=lambda: numpy.zeros((0,))) |
264 | 269 | ''' |
265 | 270 | The number of pixels of each object. |
266 | 271 | ''' |
267 | 272 |
|
268 | | - coms: numpy.ndarray = numpy.zeros((0,0)) |
| 273 | + coms: ArrayLike = dataclasses.field(default_factory=lambda: numpy.zeros((0,0))) |
269 | 274 | ''' |
270 | 275 | The center of mass of objects in pixel space. |
271 | 276 | ''' |
|
0 commit comments