• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wildjames / predictive_coding_rs / 22830269200

08 Mar 2026 09:28PM UTC coverage: 90.452% (+3.3%) from 87.11%
22830269200

Pull #10

github

web-flow
Merge 3abad3f15 into 5f8ad5902
Pull Request #10: Generalise the data boundary

457 of 502 new or added lines in 11 files covered. (91.04%)

1 existing line in 1 file now uncovered.

1601 of 1770 relevant lines covered (90.45%)

15.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.68
/src/training/cpu/singlethreaded.rs
1
//! Training orchestration for predictive coding models.
2

3
use crate::{
4
  data_handling::data_handler,
5
  error::Result,
6
  model_structure::{
7
    model::PredictiveCodingModel,
8
    model_utils::set_rand_input_and_output
9
  },
10
  training::{
11
    train_handler::TrainingHandler,
12
    configuration::TrainConfig,
13
  }
14
};
15

16
use std::sync::Arc;
17
use tracing::info;
18

19

20
pub struct SingleThreadTrainHandler {
21
  config: TrainConfig,
22
  model: PredictiveCodingModel,
23
  data: Arc<dyn data_handler::TrainingDataset>,
24
  file_output_prefix: String
25
}
26

27
impl SingleThreadTrainHandler {
28
  pub fn new(
4✔
29
    config: TrainConfig,
4✔
30
    model: PredictiveCodingModel,
4✔
31
    data: Arc<dyn data_handler::TrainingDataset>,
4✔
32
    file_output_prefix: String
4✔
33
  ) -> Self {
4✔
34
    SingleThreadTrainHandler {
4✔
35
      config,
4✔
36
      model,
4✔
37
      data,
4✔
38
      file_output_prefix
4✔
39
    }
4✔
40
  }
4✔
41
}
42

43
impl TrainingHandler for SingleThreadTrainHandler {
44
  fn get_config(&self) -> &TrainConfig {
6✔
45
    &self.config
6✔
46
  }
6✔
47
  fn get_model(&mut self) -> &mut PredictiveCodingModel {
11✔
48
    &mut self.model
11✔
49
  }
11✔
NEW
50
  fn get_data(&self) -> &dyn data_handler::TrainingDataset {
×
NEW
51
    self.data.as_ref()
×
NEW
52
  }
×
53
  fn get_file_output_prefix(&self) -> &String {
11✔
54
    &self.file_output_prefix
11✔
55
  }
11✔
56

57
  fn pre_training_hook(&mut self) -> Result<()> {
3✔
58
    info!("Starting training with single-threaded strategy");
3✔
59
    Ok(())
3✔
60
  }
3✔
61

62
  fn train_step(&mut self, _step: u32) -> Result<()> {
7✔
63
    set_rand_input_and_output(&mut self.model, self.data.as_ref());
7✔
64
    self.model.reinitialise_latents();
7✔
65

66
    // Train on this example until convergence.
67
    self.model.converge_values();
7✔
68
    self.model.update_weights();
7✔
69

70
    Ok(())
7✔
71
  }
7✔
72

73
  fn report_hook(&mut self, step: u32) -> Result<()> {
2✔
74
    let energy: f32 = self.model.read_total_energy();
2✔
75
    info!("Step {}: Current model state: energy = {:.2}", step, energy);
2✔
76
    Ok(())
2✔
77
  }
2✔
78
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc