Skip to content

feat: varying-slopes effect-term design API + plain-factor parity (#58)#67

Merged
schroedk merged 4 commits into
feature/slopesfrom
slopes/58-effect-design
Jul 1, 2026
Merged

feat: varying-slopes effect-term design API + plain-factor parity (#58)#67
schroedk merged 4 commits into
feature/slopesfrom
slopes/58-effect-design

Conversation

@schroedk

@schroedk schroedk commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

solve/Solver now accept either a categories matrix or a list[Effect] (one
factor's level codes + optional intercept + per-level slopes). Intercept-only
terms lower to the existing fixed-effects path, bit-identical to the categories
solve; slope-bearing terms are validated but rejected for now.

  • Effect (core + PyO3): eager validation — empty-effect, per-slope length naming the bad slope.
  • Design::new(effects): lowers intercept-only terms; rejects slope-bearing, naming the term.
  • Free solve/solve_batch + Solver generalized over IntoDesign (adds a Vec<Effect> impl).

Parity: Rust + Python tests assert x/demeaned bit-identical to the categories solve; error tests cover the rejection cases.

Base feature/slopes (carries prerequisite #65).

schroedk added 4 commits June 30, 2026 18:49
Add an Effect term (levels, intercept, slope covariates) that lowers to
the categories-backed Design; intercept-only effects reproduce the
categories path, slope-bearing ones are rejected (SlopesNotYetSupported)
until a later slice. Generalize solve/solve_batch over a new IntoDesign
trait covering category arrays, Vec<Effect>, and Design.
Intercept-only effects and the equivalent categories matrix run through
the same locality sort, so the result is bit-identical, not just close.
Both solves are asserted converged so the equality cannot pass vacuously.
solve and Solver accept either a categories array or a list of Effect
terms, copied out of Python so the borrowed native Effect can be rebuilt
off-GIL. Route every entry point's preconditioner through
From<PrecondInput> so the resolution lives in one place.
Cross-backend bit-identity vs the categories path, plus the empty-effect,
slope-length, and slope-rejection error surfaces.
@schroedk schroedk force-pushed the slopes/58-effect-design branch from 24371cf to c57fabd Compare June 30, 2026 19:03
@schroedk schroedk merged commit 5c4093a into feature/slopes Jul 1, 2026
3 checks passed
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