You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Do not import JAX at module import time (v3.2.1) (#21)
This commit was created on GitHub.com and signed with GitHub’s verified signature.
`import cvmatrix` previously imported JAX whenever JAX was installed, because
the module-level array/scalar type aliases (`Array`, `Scalar`, `FloatDType`,
`_TRACER_TYPES`) were built from `jax` at import time. This made downstream
packages that only use the NumPy backend pay the JAX import cost.
- Defer annotations with `from __future__ import annotations` (keeping them as
strings) and keep the aliases NumPy-only at import; `FloatDType` uses
`npt.DTypeLike` (which already admits JAX scalar dtypes without importing JAX).
- Broaden `Array`/`Scalar`/`_TRACER_TYPES` in-place to admit `jax.Array` via a
new `_enable_jax_typing()`, called only when the JAX backend is resolved. With
string annotations, typeguard resolves them against the broadened aliases at
call time, so `backend="jax"` values still pass runtime type checks.
- JAX is now imported lazily only for `backend="jax"`; `import cvmatrix` stays
JAX-free even when JAX is installed.
The NumPy and JAX backends are behavior- and result-identical to 3.2.0 (numpy
byte-identical), verified by the existing suite under typeguard for both backends.