concision_core/data/
dataset.rs

1/*
2    Appellation: dataset <module>
3    Contrib: @FL03
4*/
5use super::Records;
6
7#[derive(Clone, Copy, Default, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
8#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
9pub struct Dataset<U, V> {
10    pub records: U,
11    pub targets: V,
12}
13
14impl<U, V> Dataset<U, V> {
15    pub fn new(records: U, targets: V) -> Self {
16        Self { records, targets }
17    }
18
19    gsw! {
20        records: &U,
21        targets: &V,
22    }
23}
24
25impl<U, V> Records for Dataset<U, V> {
26    type Inputs = U;
27    type Targets = V;
28
29    fn inputs(&self) -> &Self::Inputs {
30        &self.records
31    }
32
33    fn inputs_mut(&mut self) -> &mut Self::Inputs {
34        &mut self.records
35    }
36
37    fn targets(&self) -> &Self::Targets {
38        &self.targets
39    }
40
41    fn targets_mut(&mut self) -> &mut Self::Targets {
42        &mut self.targets
43    }
44}