Skip to content

Avoid mutating Poly score arrays - #275

Merged
bashtage merged 1 commit into
pydata:masterfrom
ktz03:fix/poly-score-input-0536
Oct 15, 2026
Merged

bashtage merged 1 commit into
pydata:masterfrom
ktz03:fix/poly-score-input-0536

Conversation

@ktz03

@ktz03 ktz03 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Poly centers a floating-point scores array in place. This changes caller-owned arrays, including the parent of a sliced view, and raises ValueError: output array is read-only for read-only scores. The latter also prevents constructing a design matrix with C(a, Poly(scores)).

Center the scores into a new array before constructing the polynomial basis. Preserve the existing contrast values and column suffixes, and add direct contrast and formula/prediction regressions covering writable, read-only and shared-view inputs, with list and integer-array controls.

Validation on Windows, Python 3.13.15, NumPy 2.5.4, SciPy 1.18.1 and pandas 3.0.6:

  • The same 14 new tests produce 10 failures and 4 passing controls on the unmodified implementation, then all pass with the fix.
  • The complete suite passes 161 tests with 1 existing skip, both normally and in the official PATSY_AVOID_OPTIONAL_DEPENDENCIES=1 mode. pandas and SciPy remain installed in that compatibility-mode run.
  • The official API-reference check, Ruff 0.16.10 formatting check for both changed files and git diff --check pass.

No R runtime comparison, other platform or complete upstream CI matrix was run locally.

@codecov-commenter

codecov-commenter commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.45%. Comparing base (331879f) to head (3c5ba5d).
⚠️ Report is 83 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #275      +/-   ##
==========================================
+ Coverage   97.60%   98.45%   +0.84%     
==========================================
  Files          30       31       +1     
  Lines        3096     3110      +14     
  Branches      591      676      +85     
==========================================
+ Hits         3022     3062      +40     
+ Misses         39       27      -12     
+ Partials       35       21      -14     
Flag Coverage Δ
unittests 98.07% <100.00%> (+0.46%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bashtage
bashtage merged commit 6d9d569 into pydata:master Oct 15, 2026
21 checks passed
@bashtage

Copy link
Copy Markdown
Contributor

Thanks.

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.

3 participants