changeforest/
model_selection_result.rs

1use std::fmt;
2
3#[derive(Clone, Debug, Default)]
4pub struct ModelSelectionResult {
5    pub is_significant: bool,
6    pub p_value: Option<f64>,
7}
8
9// https://doc.rust-lang.org/rust-by-example/hello/print/print_display.html
10impl fmt::Display for ModelSelectionResult {
11    // This trait requires `fmt` with this exact signature.
12    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
13        write!(
14            f,
15            "ModelSelectionResult(is_significant={}, p_value={:?})",
16            self.is_significant, self.p_value
17        )
18    }
19}
20
21#[cfg(test)]
22mod tests {
23    use super::*;
24
25    #[test]
26    fn test_model_selection_result_default() {
27        // Clippy complains if I implement default myself. It is very essential for
28        // this crate / the algorithm that `is_significant` is initialized as `false`.
29        let result = ModelSelectionResult::default();
30        assert!(!result.is_significant);
31    }
32}