Public Access
fix y_square latent bug: keep it always a list of per-channel arrays
Accumulation.__neg__ passed y_2 = numpy.array(self.y_square), storing a 2D ndarray. A later __iadd__ on an accumulation with ndarray y_square crashed with AttributeError at the y_square.append sites (992, 1064). - __neg__ now passes a per-channel copy (values unchanged: sums of squares are invariant under negation) - __init__ normalizes ndarray y_2 to a list, so external callers cannot reintroduce the bug - y_square annotated as _YChannels Clears the remaining pyrefly errors at Accumulation.py:992 and :1064 (74 -> 72). Unit tests reproduce both crashes and pass with the fix. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
1 parent
c797aeb387
commit
27d05496ab
2 files changed
+52
-2
No files matched your search
@@ -77,7 +77,8 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
|
||||
self.use_error = error
|
||||
if self.uses_statistics():
|
||||
if (y_2 is not None):
|
||||
self.y_square = y_2
|
||||
# y_square is always kept as a list of per-channel arrays
|
||||
self.y_square: _YChannels = y_2 if isinstance(y_2, list) else list(y_2)
|
||||
elif (y_2 is None) :
|
||||
self.y_square = []
|
||||
else:
|
||||
@@ -1147,7 +1148,8 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
|
||||
tmp_y.append(numpy.array(-self.y[i], dtype="float32"))
|
||||
|
||||
if self.uses_statistics():
|
||||
r = Accumulation(x = numpy.array(self.x, dtype="float32"), y = tmp_y, y_2 = numpy.array(self.y_square), n = self.n, index = self.index, sampl_freq = self.sampling_rate, error = True)
|
||||
tmp_y_square = [numpy.array(sq) for sq in self.y_square]
|
||||
r = Accumulation(x = numpy.array(self.x, dtype="float32"), y = tmp_y, y_2 = tmp_y_square, n = self.n, index = self.index, sampl_freq = self.sampling_rate, error = True)
|
||||
else:
|
||||
r = Accumulation(x = numpy.array(self.x, dtype="float32"), y = tmp_y, n = self.n, index = self.index, sampl_freq = self.sampling_rate, error = False)
|
||||
self._copy_provenance(r)
|
||||
|
||||
Reference in new issue
Block a user