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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smoothcon-0.3.0.tar.gz.
File metadata
- Download URL: smoothcon-0.3.0.tar.gz
- Upload date:
- Size: 152.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d3887ba07013829e1d6033cb6b3f8e218158e9bd9f7dc3e65755be873b0289a
|
|
| MD5 |
bf906a6adce9979a1c077e45b117a4b1
|
|
| BLAKE2b-256 |
a98eaae2d79cb941fa324da2300ea4ff6d156aa0648fa7e466e7bbd1d2d0e15f
|
Provenance
The following attestation bundles were made for smoothcon-0.3.0.tar.gz:
Publisher:
pypi.yml on liesel-devs/smoothcon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smoothcon-0.3.0.tar.gz -
Subject digest:
7d3887ba07013829e1d6033cb6b3f8e218158e9bd9f7dc3e65755be873b0289a - Sigstore transparency entry: 2617675446
- Sigstore integration time:
-
Permalink:
liesel-devs/smoothcon@e53aac36eb11819811b3cecb5e810ecc1d5d3661 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/liesel-devs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@e53aac36eb11819811b3cecb5e810ecc1d5d3661 -
Trigger Event:
release
-
Statement type:
File details
Details for the file smoothcon-0.3.0-py3-none-any.whl.
File metadata
- Download URL: smoothcon-0.3.0-py3-none-any.whl
- Upload date:
- Size: 37.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e0155a4f60b8ce85e007a16daa9378cdafaee077faf04edc58e9d6ec4bee65d
|
|
| MD5 |
c1f5221587648d5508da5f2b9911b1ab
|
|
| BLAKE2b-256 |
90787929c063f9b2f4a5f6219534f42ec5f6392d8554992717913cbfe41546cc
|
Provenance
The following attestation bundles were made for smoothcon-0.3.0-py3-none-any.whl:
Publisher:
pypi.yml on liesel-devs/smoothcon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smoothcon-0.3.0-py3-none-any.whl -
Subject digest:
9e0155a4f60b8ce85e007a16daa9378cdafaee077faf04edc58e9d6ec4bee65d - Sigstore transparency entry: 2617675455
- Sigstore integration time:
-
Permalink:
liesel-devs/smoothcon@e53aac36eb11819811b3cecb5e810ecc1d5d3661 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/liesel-devs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@e53aac36eb11819811b3cecb5e810ecc1d5d3661 -
Trigger Event:
release
-
Statement type: