Aggregate: ARGMIN/ARGMAX return coordinates; fix RangedAggregate async passthrough - #199
Open
cboulay wants to merge 1 commit into
Open
Aggregate: ARGMIN/ARGMAX return coordinates; fix RangedAggregate async passthrough#199cboulay wants to merge 1 commit into
cboulay wants to merge 1 commit into
Conversation
AggregateTransformer returned ARGMIN/ARGMAX as a raw index into the axis it then removes from the message, so the consumer was handed an index into a dimension the output no longer describes. RangedAggregate and BinnedAggregate answer the same enum member with the axis coordinate. Drop `index_to_coordinate=False` and widen the coordinate condition from `op == TRAPEZOID` to the existing `needs_coordinates(op)`, which already covers both ARG* members. Where the axis carries no metadata `get_axis` supplies a default LinearAxis (gain=1, offset=0), so the coordinates are 0, 1, 2, ... and the result is the index after all. BREAKING: ARG* output on AggregateTransformer changes from an index to an axis coordinate. TRAPEZOID was already correct and is unaffected. Also fixes a separate bug found while reading: RangedAggregateTransformer overrode __call__ for its `bands is None` passthrough but not __acall__. BaseTransformerUnit awaits __acall__, so `bands=None` inside a graph fell through to _reset_state and raised TypeError on iterating None -- the shortcut only ever worked when the transformer was driven synchronously. Both branches now also _request_reset(), matching BinnedAggregate, so resuming with different bands cannot reuse the old slices. Closes #192
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.
Closes #192.
AggregateTransformerARG* returns coordinatesAggregateTransformerreturnedARGMIN/ARGMAXas a raw index into the aggregated axis, whileRangedAggregateTransformerandBinnedAggregateTransformerreturn the axis coordinate for the same enum member. It is worse here than for the other two, because this transformer removes the axis from the output — the consumer is handed an index into a dimension the message no longer describes, and cannot convert it without having kept the input around.The machinery was already in place;
AggregateTransformerwas opting out of it. This dropsindex_to_coordinate=Falseand widens the coordinate condition fromop == TRAPEZOIDto the existingneeds_coordinates(op), which already covers both ARG* members.Breaking. ARG* output units change from index to axis coordinate.
TRAPEZOIDwas already correct and is unaffected, and no in-repo caller uses ARG* through either transformer (fbcca.pycallsnumpy.argmindirectly). Where the axis carries no metadata,get_axissupplies a defaultLinearAxis(gain=1, offset=0), so the coordinates are 0, 1, 2, … and the result is the index after all — covered by a test.index_to_coordinatestays onaggregate_slicesfor a caller that means to index back into the array it passed in; nothing in this package sets it False any more, and the docstring now says so instead of namingAggregateTransformer.Separate bug:
RangedAggregate(bands=None)was broken in every graphFound while reading.
RangedAggregateTransformeroverrode__call__for itsbands is Nonepassthrough but not__acall__.BaseTransformerUnit.on_signalawaits__acall__, so in a graph the shortcut was skipped entirely andbands=Nonefell through to_reset_state:The shortcut only ever worked when the transformer was driven synchronously, which is why every existing test passed.
BinnedAggregateTransformeroverrides both.Both branches now also call
_request_reset(), matchingBinnedAggregate, so togglingbandstoNoneand back to a different list cannot resume on the first list's slices.Tests
test_aggregate_transformer_argminmaxupdated to expect coordinates (freqis gain=2.0/offset=1.0, so index and coordinate genuinely differ).test_aggregate_argminmax_matches_ranged— new, pins the actual invariant: a band spanning the whole axis asks the same question as the full-axis reduction, so the two transformers must agree. Guards against a future re-split.test_aggregate_argminmax_bare_axis_is_index— new, the no-metadata fallback.test_ranged_aggregate_passthrough_async/..._resume_async— new, cover the__acall__path.Full suite: 3699 passed, 5 skipped. Ruff clean.