Skip to content

Compute single-element moving sums without a running difference - #633

Open
Boulea7 wants to merge 1 commit into
pydata:masterfrom
Boulea7:fix/move-sum-single-element
Open

Boulea7 wants to merge 1 commit into
pydata:masterfrom
Boulea7:fix/move-sum-single-element

Conversation

@Boulea7

@Boulea7 Boulea7 commented Nov 30, 2026

Copy link
Copy Markdown

A moving sum over one element should equal that element in the output dtype. On master, move_sum([0.1, -0.3, 0.2], 1) returns -0.30000000000000004 and 0.19999999999999996 for the last two values. With int32, moving from 2147483647 to -2147483647 returns 2147483649.0 because the difference overflows before conversion to float64.

This handles one-element windows directly for the four native dtypes. On the 119 observations in #437, all single-element sums now agree with the input. On master, 110 differed. The patch also applies cleanly on top of #629, which addresses a large value leaving a wider window.

The four new regression cases fail on master and pass with the change. The full native test suite on macOS arm64 passed with 212 tests and one expected failure.

OpenAI Codex implemented the change and ran the tests.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant