Smoothcon - Construct basis and penalty matrices in JAX
smoothcon constructs JAX-native basis matrices and quadratic penalties for
smooth terms. It is a standalone numerical library: arrays and construction
parameters go in, and an immutable Smooth comes out.
Installation
smoothcon requires Python 3.13 or 3.14.
pip install smoothcon
With uv:
uv add smoothcon
Quick start
import jax.numpy as jnp
import smoothcon
x = jnp.linspace(0.0, 1.0, 100)
smooth = smoothcon.pspline(x, k=20, degree=3, penalty_order=2)
basis = smooth.basis(x)
penalty = smooth.penalty
The Smooth object
smooth.basis(values) evaluates the design matrix, smooth.penalty contains
the coefficient penalty, smooth.rank records its numerical rank, and
smooth.knots retains knot or center locations when applicable.
Smooth.basis supports jax.jit and finite first-order autodiff almost
everywhere for continuous smooth families. Exact derivatives at nonsmooth knot
or boundary locations and higher-order derivatives are not guaranteed. MRF
bases are discrete and excluded from the autodiff contract.
Smooth families
- P-splines, integrated-derivative B-splines, and cyclic P-splines:
pspline,bspline, andcyclic_pspline - cubic regression and cyclic cubic regression splines:
cubic_regressionandcyclic_cubic - thin-plate regression splines:
thin_plate - fixed-range Gaussian-process smooths:
gaussian_process - Markov random fields:
mrf
Transformations
Transformations return new Smooth objects and can be composed explicitly:
nonlinear = (
smooth.constrain("constant_and_linear", values=x)
.scale_penalty(values=x)
.diagonalize_penalty(values=x)
)
Available constraints are evaluated-term sum-to-zero, coefficient sum-to-zero,
constant-and-linear trend removal, and arbitrary matrices A representing
A @ coefficients == 0.
Documentation
The documentation includes the complete API reference and notes on deviations from mgcv. To inspect it locally:
uv run zensical serve
Development
uv sync --all-groups
uv run pytest
uv run ruff check .
uv run ty check
uv run mypy
uv run zensical build --clean --strict
Normal tests do not require R. See
tests/mgcv_reference/README.md for manual
oracle regeneration.
Provenance and license
The numerical constructors include Python/JAX adaptations of algorithms from
Simon N. Wood's GPL-licensed
mgcv, pinned for development and
regression testing to mgcv 1.9-4 at commit
1b6a4c8374612da27e36420b4459e93acb183f2d.
smoothcon is licensed under GPL-3.0-or-later. See
THIRD_PARTY_NOTICES.md for source provenance,
copyright notices, and academic citations.
Metadata
Release files for smoothcon 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| smoothcon-0.3.0.tar.gz | 152.1 kB | With provenance | Details for smoothcon-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| smoothcon-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for smoothcon-0.3.0-py3-none-any.whl |
Total release size: 189.1 kB
Release files / smoothcon-0.3.0.tar.gz
| Download URL | smoothcon-0.3.0.tar.gz |
|---|---|
| Size | 152.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d3887ba07013829e1d6033cb6b3f8e218158e9bd9f7dc3e65755be873b0289a
|
|
BLAKE2b-256 checksum How to use checksums |
a98eaae2d79cb941fa324da2300ea4ff6d156aa0648fa7e466e7bbd1d2d0e15f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / smoothcon-0.3.0-py3-none-any.whl
| Download URL | smoothcon-0.3.0-py3-none-any.whl |
|---|---|
| Size | 37.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9e0155a4f60b8ce85e007a16daa9378cdafaee077faf04edc58e9d6ec4bee65d
|
|
BLAKE2b-256 checksum How to use checksums |
90787929c063f9b2f4a5f6219534f42ec5f6392d8554992717913cbfe41546cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logSecurity for smoothcon 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for smoothcon-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.