Skip to content

Avoid integer overflow in raw polynomial bases - #283

Open
lllleolin-max wants to merge 1 commit into
matthewwardrop:mainfrom
lllleolin-max:codex/avoid-integer-overflow-in-raw-polynomials
Open

lllleolin-max wants to merge 1 commit into
matthewwardrop:mainfrom
lllleolin-max:codex/avoid-integer-overflow-in-raw-polynomials

Conversation

@lllleolin-max

Copy link
Copy Markdown

poly(x, raw=True) raises integer-valued inputs to powers in their original dtype, silently overflowing even for ordinary values such as int8 data [10, 20] squared. Promote integer inputs to float64 before taking powers, preserving the existing floating-point and complex input dtypes. Tests compare int8/int32/int64 inputs against exact Python integer powers and cover formula materialization, unchanged input arrays, and preserved float32/float64/longdouble/complex64/complex128 values and dtypes.

Validation: the added regression tests fail on main (81e675b) and pass with this patch. Related tests: python -m pytest tests/transforms/test_poly.py tests/transforms/test_contrasts.py -q. Changed files pass ruff check and ruff format.

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