Add custom statistics (per-channel & cross-channel, multi-output) to StatsAggregator - #67
Open
tombonfert wants to merge 8 commits into
Open
Add custom statistics (per-channel & cross-channel, multi-output) to StatsAggregator#67tombonfert wants to merge 8 commits into
tombonfert wants to merge 8 commits into
Conversation
- Introduced the CrossChannelStatistic class to facilitate cross-channel custom statistics in the query engine. - Updated StatsAggregator to support cross-channel and per-channel custom statistics, including validation and normalization of input statistics. - Enhanced documentation for both classes, detailing parameters, expected behaviors, and usage examples. - Added integration tests to validate the functionality of custom statistics within the StatsAggregator, ensuring correct computation and output. - Updated existing tests to accommodate changes in the output schema, including cross-channel values in the results.
- Removed the CrossChannelStatistic class and integrated its functionality into a new custom_statistic module, which now includes both CrossChannelStatistic and PerChannelStatistic classes. - Updated StatsAggregator to utilize the new custom statistics classes, enhancing support for both cross-channel and per-channel custom statistics. - Implemented parameter handling for custom statistics, allowing for dynamic configuration during aggregation. - Added validation for custom statistic parameters to ensure correct usage and prevent errors. - Enhanced unit and integration tests to cover the new functionality and validate the behavior of custom statistics with parameters.
- Replaced dict-based custom statistic registration with lists of `PerChannelStatistic`/`CrossChannelStatistic` descriptors. - Added required `aggregation_labels` to each descriptor; functions now return a sequence of values mapped positionally to those labels. - Updated query-engine and reporting-layer `StatsAggregator` validation, definition hashing, and fact-row generation to handle multiple outputs per statistic. - Added integration tests for multi-output per-channel and cross-channel custom statistics.
- Add API reference for impulse_query_engine.analyze.query.aggregations.custom_statistic. - Update StatsAggregator, data model, report reference, and skill docs to cover per-channel and cross-channel custom statistics. - Refresh CalculatedChannel API docs to reflect get_expression returning the wrapped expression.
…positional-only partial handling - Incorporate `__defaults__` and `__kwdefaults__` into the custom statistic fingerprint so behavior changes carried only by default arguments alter the definition hash. - Guard against `None` keywords when unwrapping `functools.partial` to avoid crashes for positionally-bound partials. - Add unit tests covering default-argument hash stability and positional-only partial hashing.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #67 +/- ##
==========================================
+ Coverage 88.72% 88.94% +0.22%
==========================================
Files 59 60 +1
Lines 4826 5013 +187
Branches 552 596 +44
==========================================
+ Hits 4282 4459 +177
- Misses 445 451 +6
- Partials 99 103 +4
🚀 New features to boost your workflow:
|
…ion hash and canonicalize StatsAggregator event_timestamps - Query engine `StatsAggregator.build` now returns a canonical `event_timestamps` list with one entry per non-degenerate interval, aligned 1:1 with `numeric_values` per signal and `cross_channel_values`; removes the previous series-major repetition. - Reporting layer includes `channel_names` in `StatsAggregator` and `PointValueAggregator` definition hashes, and each cross-channel custom statistic's `channel_name` in its fingerprint, so renames force a recompute and stale fact rows are pruned in incremental mode. - Update reference docs, skill docs, and tests to reflect the new hash inputs and canonical timestamp layout.
…c descriptors in docs
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
Extends StatsAggregator in both the query engine and the reporting layer so users can inject arbitrary statistics functions alongside the built-ins (min/max/mean/median/start/end).
Two kinds of custom statistics
Self-describing descriptors
Reporting integration
Tests
Test Plan
Checklist