Own axes retained in processor state; Flatten variable-chunk hash; RangedAggregate coordinate-axis fixes - #181
Merged
Merged
Conversation
Variable-length chunks along the preserve axis (e.g. irregular time chunks) previously reset FlattenTransformer state and rebuilt the merged output axis on every size change. Hash only the non-preserve shape and take the preserve-axis length from each live message when reshaping.
Input axes may be views into an ezmsg transport buffer whose lifetime ends after the current subscriber callback. Any axis object retained in processor state beyond that call must own its memory: - HybridAxisArrayBuffer._initialize: deepcopy the non-target axes kept in the output template message. - ConcatProcessor._build_cached_axes: deepcopy cached pass-through axes. - FilterbankTransformer._reset_state: deepcopy template axes (the shallow dict copy still shared the axis objects). - CWTTransformer._reset_state: deepcopy template axes. Tests assert outputs reuse one processor-owned axis object rather than aliasing input axes.
_reset_state stored a reference to the input coordinate axis data, and _process reads it on later messages (trapezoid x-coordinates, argmin/argmax lookups); copy it into processor-owned memory since the input axis may be a view into an ezmsg transport buffer. The CoordinateAxis output-label paths were also broken: the numeric branch appended the band mean and then hit ax_dat.append(sl_dat) with sl_dat unbound (NameError on the first band), and the string branch indexed ax_vec with the band values instead of the matched indices. Labels are now 'first - last' of the matched entries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Input axes may be views into an ezmsg transport buffer whose lifetime ends after the current subscriber callback, so any axis object a processor retains across calls must own its memory. This PR audits every
_reset_state/template-caching site in the package and fixes the ones that aliased input axes, plus two adjacent bugs found during the audit.Axes ownership (deep-copy retained axes)
_initializedeep-copies the non-target axes kept in the output template message._build_cached_axesdeep-copies cached pass-through axes.ax_vecstored a reference to the input coordinate axis data and read it on later messages (trapezoid x-coordinates, argmin/argmax lookups); now copied.Audited-clean (no change needed): slicer and affinetransform already copy via
np.array(); fir_hilbert copies its delay buffer; window/spectrum/adaptive_lattice_notch cache only scalar-field or freshly-allocated axes; remaining_reset_stateimplementations cache no message-derived axis objects.Flatten: variable preserve-axis chunk sizes
_hash_messageexcluded the preserve-axis length so variable-length time chunks no longer reset state and rebuild the merged output axis; reshape takes the preserve-axis length from each live message.RangedAggregate: CoordinateAxis band labels were broken
The numeric branch raised
NameError(sl_datunbound) on the first band, and the string branch indexedax_vecwith the band values instead of the matched indices. Labels are now"first - last"of the matched entries.Tests