microBioRust_heatmap/
heatmap_data.rs

1//! This module contains the data structure for the heatmap
2
3use serde::{Serialize, Deserialize};
4
5#[derive(Serialize, Deserialize, Clone, Debug)]
6pub struct HeatmapData {
7   pub values: Vec<Vec<i32>>,
8   pub x_labels: Vec<String>,
9   pub y_labels: Vec<String>,
10}
11
12impl HeatmapData {
13    // Constructor method
14    pub fn new() -> Self {
15        HeatmapData {
16            values: vec![vec![0]],
17            x_labels: Vec::new(),
18            y_labels: Vec::new(),
19        }
20    }
21}
22
23#[cfg(test)]
24mod tests {
25    use super::*;
26
27    #[test]
28    fn test_new() {
29        let heatmap_data = HeatmapData::new();
30        assert_eq!(heatmap_data.values, vec![vec![0]]);
31        assert_eq!(heatmap_data.x_labels, Vec::<String>::new());
32        assert_eq!(heatmap_data.y_labels, Vec::<String>::new());
33    }
34}