All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Lowered the minimum supported Python version from 3.11 to 3.10 (
requires-python = ">=3.10, <3.15"). The code base uses no Python-3.11-only features; this broadens compatibility for downstream packages that still support Python 3.10. Python 3.10 is now included in the CI test matrices. No functional changes.
- The fold-index parameters (
validation_indices/val_indices) are now annotated with a newIndexArrayalias that_enable_jax_typing()broadens to admitjax.Array, matching theArray/Scalaraliases introduced in 3.2.1. Previously they were annotated asnpt.NDArray[np.int_]only, so running the test suite withtypeguardinstrumentation enabled failed on thejax.jit/jax.vmaptrace tests (the indices are abstract tracers under tracing). Runtime behavior is unchanged; this only affects runtime type checking. - CI now actually enables
typeguardinstrumentation during tests: the test command passed--typeguard-packages=cvmatrix/(a path, with a trailing slash) instead of the package namecvmatrix, which silently instrumented nothing and masked the annotation issue above.
import cvmatrixno longer imports JAX, even when JAX is installed. JAX was previously imported at module load time to broaden the array/scalar type hints so thatbackend="jax"values satisfy runtime type checking; it is now imported lazily, only when the JAX backend is actually resolved (backend="jax"). The array/scalar type aliases start NumPy-only and are broadened in-place to also admitjax.Arraythe first time the JAX backend is used (annotations are deferred viafrom __future__ import annotations, sotypeguardresolves them against the broadened aliases at call time). This keeps NumPy-only import paths — and downstream packages that use only the NumPy backend — free of the JAX import cost. Thenumpyandjaxbackends are behavior- and result-identical to 3.2.0.
- Optional JAX backend for
CVMatrixviabackend="jax"(aLiteral["numpy", "jax"]; default remains"numpy"). All array operations are routed through a resolved array namespace (numpyorjax.numpy), so the per-foldtraining_XTX/training_XTY/training_XTX_XTY/training_statisticscomputations can be traced byjax.jitand batched withjax.vmapon CPU/GPU/TPU. Install withcvmatrix[jax]. - Backend-neutral, trace-safe standard-deviation clamping (
maximum/whereinstead of boolean-mask assignment). Degenerate-fold validation (ValueErrors) still fires for eager (numpy or concrete jax) execution; underjax.jit/jax.vmaptracing the check is deferred to a host-side pre-flight by the caller.
- Switched build and development tooling from Poetry to uv: the project now uses PEP 621
[project]metadata, thehatchlingbuild backend, and a PEP 735[dependency-groups]dev group (poetry.lockis replaced byuv.lock). The published package, its runtime dependencies, and thejaxextra are unchanged.
- The numpy backend is byte-identical to previous releases (verified against the existing test suite) and performance-neutral.
CVMatrixandPartitionercan now be imported withfrom cvmatrix import CVMatrix, Partitionerorimport cvmatrixfollowed bycvmatrix.CVMatrixandcvmatrix.Partitioner.
Partitionerclass for managing cross-validation folds
CVMatrixno longer internally stores a dictionairy of validation indices. This responsibility is offloaded toPartitionersoCVMatrixcan be pickled more efficiently when used in a multiprocessing context such as by the ikpls package [1].
-
Weighted matrix products
$\mathbf{X}^{\mathbf{T}}\mathbf{W}\mathbf{Y}$ support without increasing time or space complexity - Generalization of the fast cross-validation algorithms by Engstrøm and Jensen to handle weighted cases
- Support for weighted centering and weighted scaling based on training set statistical moments
- All 16 (12 unique) combinations of weighted column-wise centering and scaling for X and Y matrices
- Extended algorithms to correctly handle weighted cases while maintaining efficiency
- Enhanced
CVMatrixclass to accept sample weights
- The weighted extension maintains the same computational complexity as the unweighted algorithms
- Formal description of the weighted generalization to be announced in upcoming publication
- Implementation of fast cross-validation algorithms by Engstrøm and Jensen [2] for computation of training set
$\mathbf{X}^{\mathbf{T}}\mathbf{X}$ and$\mathbf{X}^{\mathbf{T}}\mathbf{Y}$ -
CVMatrixclass for efficient kernel matrix computation in cross-validation settings - Support for arbitrary row-wise preprocessing of data
- Support for column-wise centering and scaling of X and Y based on training set statistics
- Methods for computing:
-
training_XTX_XTY(): Both training set kernel matrices and statistics -
training_XTX(): Training set$\mathbf{X}^{\mathbf{T}}\mathbf{X}$ and X statistics -
training_XTY(): Training set$\mathbf{X}^{\mathbf{T}}\mathbf{Y}$ and statistics
-
- Comprehensive test suite and benchmarks
- Documentation at cvmatrix.readthedocs.io
- Correct handling of column-wise centering and scaling without data leakage
- Efficient computation of training set moments (means and standard deviations)
- Support for all combinations of centering and scaling options for X and Y
- Significantly faster than naive implementations for cross-validation scenarios
- Engstrøm, O.-C. G. and Jensen, M. H. (2025). Fast Partition-Based Cross-Validation With Centering and Scaling for $\mathbf{X}^\mathbf{T}\mathbf{X}$ and $\mathbf{X}^\mathbf{T}\mathbf{Y}$
- IKPLS. Fast CPU and GPU Python implementations of Improved Kernel Partial Least Squares (PLS) by Dayal and MacGregor (1997) and Fast Partition-Based Cross-Validation With Centering and Scaling for XTX and XTY by Engstrøm and Jensen (2025). This package also includes options to use sample weights for PLS modeling.