Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

ADR 0015 - Solver dependencies are required but imported only where used

0015 - Solver dependencies are required but imported only where used

Context

ADR 0001 - Thin foundation posture refused solver libraries so that a units-only consumer would not inherit diffrax and optimistix. Two later changes added three runtime dependencies without revising it:

Measured on 2026-09-24 with a fresh interpreter per import:

ImportLoads diffrax and optimistixLoads sympy
jaxstro, jaxstro.units, jaxstro.constantsnono
jaxstro.coords, jaxstro.numerics, jaxstro.quadyesno
jaxstro.registrynono

The coordinate and quadrature imports load the solvers because jaxstro/numerics/__init__.py imports numerics.lane_emden eagerly. The 2026-09-23 architecture review measured the jaxstro.numerics import at 570 ms cumulative, of which lane_emden was 210 ms (one cold -X importtime run).

Decision

diffrax, optimistix, and sympy are required runtime dependencies of jaxstro. Only the modules that use them may import them: jaxstro.numerics.lane_emden for diffrax and optimistix, and jaxstro.registry for sympy, which it already imports lazily. Importing jaxstro.units, jaxstro.constants, jaxstro.coords, jaxstro.numerics, or jaxstro.quad must load none of the three, and a test enforces this.

This supersedes 0001’s refusal of solver libraries. It keeps 0001’s rule that a consumer of the lightweight surfaces does not pay for the solvers, and applies it at import time instead of at install time.

Rationale

Consequences