scouter_types/spc/
drift.rs

1use crate::util::PyHelperFuncs;
2use chrono::{DateTime, Utc};
3use pyo3::prelude::*;
4use serde::{Deserialize, Serialize};
5use std::collections::BTreeMap;
6
7#[pyclass]
8#[derive(Debug, Clone, Serialize, Deserialize, Default)]
9pub struct SpcDriftFeature {
10    #[pyo3(get)]
11    pub created_at: Vec<DateTime<Utc>>,
12
13    #[pyo3(get)]
14    pub values: Vec<f64>,
15}
16
17#[pymethods]
18impl SpcDriftFeature {
19    pub fn __str__(&self) -> String {
20        // serialize the struct to a string
21        PyHelperFuncs::__str__(self)
22    }
23}
24
25#[pyclass(name = "BinnedSpcFeatureMetrics")]
26#[derive(Debug, Clone, Serialize, Deserialize, Default)]
27pub struct SpcDriftFeatures {
28    #[pyo3(get)]
29    pub features: BTreeMap<String, SpcDriftFeature>,
30}
31
32#[pymethods]
33impl SpcDriftFeatures {
34    pub fn __str__(&self) -> String {
35        // serialize the struct to a string
36        PyHelperFuncs::__str__(self)
37    }
38}
39
40impl SpcDriftFeatures {
41    pub fn is_empty(&self) -> bool {
42        self.features.is_empty()
43    }
44}