Skip to main content

gam_problem/
block_role.rs

1use serde::{Deserialize, Serialize};
2
3/// Role of a coefficient block within a multi-parameter model.
4#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
5pub enum BlockRole {
6    /// Single-parameter GAM (standard GLM/GAM mean model).
7    Mean,
8    /// Location parameter in GAMLSS / survival location-scale.
9    Location,
10    /// Scale (log-sigma) parameter in GAMLSS / survival location-scale.
11    Scale,
12    /// Time/baseline hazard block in survival models.
13    Time,
14    /// Threshold block in survival models.
15    Threshold,
16    /// Link-wiggle correction block.
17    LinkWiggle,
18}
19
20impl BlockRole {
21    #[inline]
22    pub const fn name(self) -> &'static str {
23        match self {
24            Self::Mean => "mean",
25            Self::Location => "location",
26            Self::Scale => "scale",
27            Self::Time => "time",
28            Self::Threshold => "threshold",
29            Self::LinkWiggle => "link-wiggle",
30        }
31    }
32}
33
34#[cfg(test)]
35mod tests {
36    use super::*;
37
38    #[test]
39    fn name_mean() {
40        assert_eq!(BlockRole::Mean.name(), "mean");
41    }
42
43    #[test]
44    fn name_location() {
45        assert_eq!(BlockRole::Location.name(), "location");
46    }
47
48    #[test]
49    fn name_scale() {
50        assert_eq!(BlockRole::Scale.name(), "scale");
51    }
52
53    #[test]
54    fn name_time() {
55        assert_eq!(BlockRole::Time.name(), "time");
56    }
57
58    #[test]
59    fn name_threshold() {
60        assert_eq!(BlockRole::Threshold.name(), "threshold");
61    }
62
63    #[test]
64    fn name_link_wiggle() {
65        assert_eq!(BlockRole::LinkWiggle.name(), "link-wiggle");
66    }
67
68    #[test]
69    fn eq_reflexive() {
70        assert_eq!(BlockRole::Mean, BlockRole::Mean);
71        assert_ne!(BlockRole::Mean, BlockRole::Scale);
72    }
73}