concision_core/data/
dataset.rs1use 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> core::fmt::Display for Dataset<U, V>
26where
27 U: core::fmt::Display,
28 V: core::fmt::Display,
29{
30 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
31 write!(
32 f,
33 "{{\n records: {},\n targets: {}\n}}",
34 self.records, self.targets
35 )
36 }
37}
38
39impl<U, V> Records for Dataset<U, V> {
40 type Inputs = U;
41 type Targets = V;
42
43 fn inputs(&self) -> &Self::Inputs {
44 &self.records
45 }
46
47 fn inputs_mut(&mut self) -> &mut Self::Inputs {
48 &mut self.records
49 }
50
51 fn targets(&self) -> &Self::Targets {
52 &self.targets
53 }
54
55 fn targets_mut(&mut self) -> &mut Self::Targets {
56 &mut self.targets
57 }
58}