testing.check_prior
testing.check_prior(prior, params)Check a prior against the core contracts.
- It satisfies
PriorWithCovariance(log_prob,location,add_precision_to,cov_mv), andlog_prob(params)is a tensor with one finite element. - For a
TunablePrior,tunable()returns positive tensors that are leaves of the prior itself (not copies), alone or in a mapping. add_precision_tokeeps the operator type, block by block for aBlockDiag. It is tried onDiag,BlockDiag[Diag],LowRankPlusDiag, and for at mostDENSE_MAX_PARAMSparameters onKronEigenbasisper block,Dense,BlockDiag[Dense]andJoint[Dense]. Refusing one withStructureErrororCapabilityErroris allowed; refusing all is not. Types compare exactly, so returning a subclass of the operator’s type fails.cov_mvis the inverse of the prior’s precision: \(\mathrm{cov\_mv}(v) = P^{-1} v\) for a random \(v\), where \(P\) is read off by adding the prior to each zero operator it accepts:Diag,BlockDiag[Diag], and for at mostDENSE_MAX_PARAMSparametersDense,BlockDiag[Dense]andJoint[Dense]. Refusing all fails.
Every equality holds up to RTOL. Errors that the prior raises, other than a refusal by add_precision_to, propagate.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| prior | PriorWithCovariance | The prior. | required |
| params | Params | Float64 parameter mapping. Blocks follow Layout.by_module(params). |
required |
Raises
| Name | Type | Description |
|---|---|---|
| AssertionError | A law above fails. The message names the law and prior. |
|
| ValueError | params are not float64, or the prior accepts a single-block zero operator (Diag, Dense) and the params are not grouped by module. |