1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
pub struct DiffusionMapHyperParams {
    steps: usize,
    embedding_size: usize,
}

pub struct DiffusionMapHyperParamsBuilder {
    steps: usize,
    embedding_size: usize,
}

impl DiffusionMapHyperParamsBuilder {
    pub fn steps(mut self, steps: usize) -> Self {
        self.steps = steps;

        self
    }

    pub fn build(self) -> DiffusionMapHyperParams {
        DiffusionMapHyperParams::build(self.steps, self.embedding_size)
    }
}

impl DiffusionMapHyperParams {
    // Violates the convention that new should return a value of type `Self`
    #[allow(clippy::new_ret_no_self)]
    pub fn new(embedding_size: usize) -> DiffusionMapHyperParamsBuilder {
        DiffusionMapHyperParamsBuilder {
            steps: 10,
            embedding_size,
        }
    }

    pub fn steps(&self) -> usize {
        self.steps
    }

    pub fn embedding_size(&self) -> usize {
        self.embedding_size
    }

    pub fn build(steps: usize, embedding_size: usize) -> Self {
        DiffusionMapHyperParams {
            steps,
            embedding_size,
        }
    }
}