1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Custom-family error type and its String conversions.
use super::*;
#[derive(Debug, Clone, Error)]
pub enum CustomFamilyError {
#[error("custom-family invalid input in {context}: {reason}")]
InvalidInput {
context: &'static str,
reason: String,
},
#[error("custom-family optimization error in {context}: {reason}")]
Optimization {
context: &'static str,
reason: String,
},
#[error("{reason}")]
DimensionMismatch { reason: String },
#[error("{reason}")]
NumericalFailure { reason: String },
#[error("{reason}")]
ConstraintViolation { reason: String },
#[error("{reason}")]
UnsupportedConfiguration { reason: String },
#[error("{reason}")]
BasisDecompositionFailed { reason: String },
/// Pre-fit cross-block identifiability audit refused the fit. The
/// joint design across `ParameterBlockSpec`s carries a rank
/// deficiency that the post-`joint_null_rotation` absorption did
/// not resolve: two or more blocks contribute the same direction,
/// or a structural >2-way alias was detected without per-pair
/// attribution. The full `IdentifiabilityAudit` is held so
/// consumers (logs, structured-error sinks, the seed driver's
/// classifier) can extract the alias pairs and the summary string
/// without reparsing.
#[error("identifiability audit refused the fit: {}", audit.summary)]
IdentifiabilityFailure {
audit: crate::identifiability::audit::IdentifiabilityAudit,
},
/// MAP estimate uniqueness condition `ker(J^T W J) ∩ ker(S) = {0}` is
/// violated. A null direction of `J^T W J` carries zero penalty
/// curvature, so the posterior is flat along that direction and the
/// MAP is non-unique. The structured [`MapUniquenessError`] names the
/// dominant block so the caller can add the missing penalty or remove
/// the unpenalised direction.
#[error("MAP estimate non-unique: {}", error)]
MapUniquenessFailure {
error: crate::identifiability::audit::MapUniquenessError,
},
}
impl From<String> for CustomFamilyError {
fn from(value: String) -> Self {
Self::InvalidInput {
context: "custom-family string boundary",
reason: value,
}
}
}
impl From<CustomFamilyError> for String {
fn from(value: CustomFamilyError) -> Self {
value.to_string()
}
}