Repository navigation
feat(operators): a window may stop at each group's edge - #1260
Merged
Merged
Conversation
`sum_back(x, over=t, within=w, by=lookup)` builds on both lanes. Positions are counted inside the group the lookup makes, so a window at the first hour of a representative day reaches back over that day's own hours and no further, and a width declared over the group's dimension is read through the lookup — one window length per day, per season, per scenario. Both lanes walk a partition the same way they already walk a shift's: the relational one ranks the dim table inside each group and joins the landing position back on `(group, position)`; the eager one gathers each lag through `_gather_in_groups`. `_walked` and `_named_amount` are what the two operators now share, a translation having had both inline. An hour the lookup places in no group reaches nothing at all, itself included, which is the one way a window loses a row it would otherwise keep. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Merging this PR will not alter performance
Comparing Footnotes
|
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.
Follows #1258, which merged while this was being written — so it is against
mainrather than stacked.Note
The following content was generated by AI.
sum_back(x, over=t, within=w, by=lookup)builds on both lanes, so the refusal#1258 added comes straight back out. Positions are counted inside the group the
lookup makes: a window at the first hour of a representative day reaches back
over that day's own hours and stops there.
What it takes
sum_back(started, over=t, within=3, by=day_of)…, by=day_of, edge='wrap'within=upwithupoverdayday_ofplaces nowhereThat last row is the one behaviour a window did not have before: unpartitioned
it always contains the position it sits at, so every row is built.
How
Both lanes already walk a partitioned shift, and the window walks it the
same way — the relational lane ranks the dim table inside each group and joins
the landing position back on
(group, position); the eager lane gathers eachlag through
_gather_in_groups. What was inline intranslate_fragmentis now_walkedand_named_amount, read by both operators, so the rank, the span andthe per-group key rewrite have one home rather than two.
The one thing that is not shared: a per-group width has to go through
_per_groupon the eager lane before thewithin > lagcomparison, or itbroadcasts the constraint onto the group's dimension — measured, the eager
constraint came back as
[t: 6, day: 2]against the relational lane's six rows.Verified
suite
3106 passed, 249 skipped, 1 xfailed; sweep at depth 32782 passed.The 35 failures are
xpress-parametrised and pre-existing on this machine(the Community licence), red on
maintoo.ruff check·ruff format --check .·pyrefly0 errors.test_both_lanes_read_every_keyword_the_language_declaresis narrowed asbuild(deps): a rule the language now enforces has one home again #1258 said it would be:
_call's interception is credited only to theoperators it spells out by name, so an eager operator that ignores a keyword
the lowering builds is red. That is what the guard was measured missing.
mutation table:
reindex.py:133-137)reindex.py:110-111)operators.py:229)Deliberately not done
model in
examples/; the representative-day case that wants it ispypsa_min_up_downunder time-series clustering, which this repository doesnot carry.
shift's stray-dim case with a partition still has no test in math-spec(noted on build(deps): a rule the language now enforces has one home again #1258); this PR does not add one there.