Repository navigation
Conversation
…l lists sklearn orders a kernel's hyperparameters alphabetically by attribute name, so a positional params= list for a kernel with two or more free hyperparameters could silently swap their priors. params= now accepts a mapping keyed by kernel_param_names(kernel); a positional list is accepted only when the kernel has a single free hyperparameter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A parametric term that overflowed (a huge kernel amplitude) put inf into the covariance; scipy's check_finite then raised ValueError, which _factor did not catch, so log_posterior raised instead of returning -inf. Each term's value on its active rows is now checked: at a theta a non-finite value is zero density, and in a constant term it is a declaration error raised at construction with the term named. Overflow in the assembled sums is caught at factorisation the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A frozen scipy logpdf spends ~100 us per call on argument handling, a quarter of a cheap posterior evaluation with a dozen parameters. The three families get exact closed forms; hypsecant also stops overflowing to -inf past |x| ~ 710 (log cosh via logaddexp), which made finite-difference optimisers see inf - inf. Everything else still calls dist.logpdf. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review findings on 2d5a05b. The per-term finite check on the likelihood path was redundant (scipy's check_finite already caught it), cost ~12% at N=1000, and could not be tested. Now the factorisations and solves run unchecked (scipy returns NaN/inf factors rather than raising), and the compiled constraint reads a non-finite d2 or logdet as zero density. That one check also fixes the Woodbury inf - inf = NaN on an overflowing residual, which predates this branch. - distance runs under np.errstate, so overflowing thetas no longer warn on every call (they did, and failed under -W error) - a rejected covariance containing NaN warns once per constraint, pointing to constraint.matrix(theta) to name the term - constant terms are checked once at construction, on their contribution (squares included), and a constant covariance with a non-finite logdet raises; a NaN matrix term reaches that check instead of failing as 'not symmetric' Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review findings on 2d5a05b. matrix() leaked the private _SingularCovariance with a ~380-character dataclass repr, and on the base branch a bad row gave NaN draws that turned the whole percentile band NaN. - matrix() raises a plain ValueError naming the term (or, when only their sum overflows, saying so) - predictive_draws (model_only and given= too), grid_draws and gp_predictive_draws check the final mean and covariance of each row and raise naming the row and its parameter values - heldout_log_predictive(given=) returns -inf at such a row, as it already did without given= - KernelTerm uses Term's short repr A finite but singular covariance is still drawn from: term subsets are legitimately rank-deficient. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review findings on bbecb86 and 3a644d6. - norm: Python-float ** raised OverflowError past |z| ~ 1e154, crashing log_posterior where it used to return -inf; now z*z in scipy's operation order (bit-identical to scipy where finite) - uniform: 'loc <= v <= loc+scale' disagreed with scipy by one ulp at the upper edge; now 0 <= (v-loc)/scale <= 1, as scipy computes it - families are matched by exact type, so a user distribution named 'norm' falls back to its own logpdf - params=: a set (or a dict as a multi-element value) silently reordered an anisotropic hyperparameter's priors; only a Parameter, list or tuple is accepted. A key naming a fixed hyperparameter is reported as fixed. - tests: the closed-form test now asserts the fast path is in use (it passed with the fast path disabled), and no longer asserts scipy's hypsecant overflow; kernel_param_names is in the API reference Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
matrix() raising when only a low-rank product overflows, and predictive_draws raising on a non-finite prediction whose covariance is finite. Each test fails with its check removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
beykyle
marked this pull request as draft
October 25, 2026 14:09
The fast path for norm, uniform and hypsecant replaced the user's prior with a hand-rolled copy, and needed its own exactness and overflow fixes. Priors are evaluated by dist.logpdf again, exactly as handed in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chol_logdet takes check_finite instead of having a private twin, and the free-element count of a kernel is sklearn's kernel.n_dims rather than a hand-written sum. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A line calibrated against data with a two-scale defect, with a three-component spectral-mixture discrepancy written as a user sklearn kernel and declared through T.kernel with a keyed params= mapping. - periodogram-seeded multistart MAP inside problem.bounds (recipe 33) - each component backed out on a fine grid with gp_predictive_draws(conditioned=True) (recipes 7, 40) - the identifiability of theta: the L2 projection theta* is the only recoverable target, and Plumlee's orthogonal kernel, a second user kernel, makes it the estimand - an emcee chain against each Laplace approximation: they agree for the orthogonal discrepancy; for Kennedy-O'Hagan the chain is several times wider, reaches theta_true, and the Laplace summary was wrong in both location and width Registered in the notebook index test, the design document's table and the examples toctree. Runtime about 930 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- normalization_and_covariance_structure: the first section was an H3 directly under the H1 title (myst.header, non-consecutive level) - spectral_mixture_discrepancy: a relative link to gp_discrepancy.ipynb does not resolve through the docs/examples symlink (myst.xref_missing); name the notebook in backticks instead, as the docs do elsewhere Checked with sphinx-build -W --keep-going, intersphinx aside (its inventories are unreachable from the build machine used). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three fixes:
kernel(params=)is keyed by hyperparameter name. sklearn orders a kernel's hyperparameters alphabetically by attribute name, so a positional list for a kernel with two or more free hyperparameters could silently swap their priors.log_posterioras a scipyValueErrorand crash the sampler.norm,uniformandhypsecantuse closed-formlogpdf. A frozen scipylogpdfcosts ~100 µs per call; a 10-parameterlog_posteriordrops from ~0.94 ms to ~0.25 ms.Behaviour changes
params=kernel_param_names(kernel), e.g.params={"length_scale": ell, "periodicity": per}.TypeError.Likelihood at an invalid θ (non-finite prediction or covariance): returns
-inf, never raises.CompiledConstraint._statstreats a non-finited2orlogdetas zero density. The hot path does no per-term scanning.d2 = inf - inf = NaN, solog_posteriorwasnanand emcee raised.RuntimeWarningon every evaluation.constraint.matrix(theta), which names the term.Construction: constant terms are checked once, and a non-finite contribution raises
ValueErrornaming the term. A NaN matrix term now gets that error instead of "not symmetric".Predictives at an invalid θ: raise a public
ValueError. Previously they returned NaN draws, which made the whole percentile band NaN.predictive_draws(includingmodel_onlyandgiven=),grid_draws,gp_predictive_drawsandmatrix().heldout_log_predictive(given=)returns-infat such a row, as it already did withoutgiven=.Priors
normanduniformare bit-identical to scipy wherever scipy is finite. They return-infinstead of raising wherezoverflows.hypsecantstays finite in the tails, where scipy's overflows to-infpast |x| ≈ 710.dist.logpdf.Other:
KernelTermusesTerm's short repr.kernel_param_namesis added to the API reference.