Skip to content

Commit

Permalink
testing_set_weights method removed from BlockTrait as its only used i…
Browse files Browse the repository at this point in the history
…n tests
  • Loading branch information
ggaspersic committed Aug 18, 2023
1 parent 0f0ff4d commit c96961f
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 27 deletions.
7 changes: 0 additions & 7 deletions src/block_ffm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -968,13 +968,6 @@ impl<L: OptimizerTrait + 'static> BlockTrait for BlockFFM<L> {
)?;
Ok(())
}

/// Sets internal state of weights based on some completely object-dependent parameters
fn testing_set_weights(&mut self, index: usize, w: &[f32]) -> Result<(), Box<dyn Error>> {
self.weights[index] = w[0];
self.optimizer[index].optimizer_data = self.optimizer_ffm.initial_data();
Ok(())
}
}

mod tests {
Expand Down
7 changes: 0 additions & 7 deletions src/block_lr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,4 @@ impl<L: OptimizerTrait + 'static> BlockTrait for BlockLR<L> {
input_bufreader,
)
}

/// Sets internal state of weights based on some completely object-dependent parameters
fn testing_set_weights(&mut self, index: usize, w: &[f32]) -> Result<(), Box<dyn Error>> {
self.weights[index].weight = w[0];
self.weights[index].optimizer_data = self.optimizer_lr.initial_data();
Ok(())
}
}
7 changes: 0 additions & 7 deletions src/block_neural.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,6 @@ impl<L: OptimizerTrait + 'static> BlockTrait for BlockNeuronLayer<L> {
)?;
Ok(())
}

/// Sets internal state of weights based on some completely object-dependent parameters
fn testing_set_weights(&mut self, index: usize, w: &[f32]) -> Result<(), Box<dyn Error>> {
self.weights[index] = w[0];
self.weights_optimizer[index].optimizer_data = self.optimizer.initial_data();
Ok(())
}
}

mod tests {
Expand Down
5 changes: 4 additions & 1 deletion src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ mod tests {
use regressor::BlockTrait;
use regressor::Regressor;

use crate::optimizer::OptimizerTrait;
use tempfile::tempdir;

#[test]
fn save_empty_model() {
let vw_map_string = r#"
Expand Down Expand Up @@ -299,7 +301,8 @@ B,featureB

for i in 0..block_ffm.get_serialized_len() {
// it only happens that this matches number of weights
block_ffm.testing_set_weights(i, &[1.0f32]).unwrap();
block_ffm.weights[i] = 1.0;
block_ffm.optimizer[i].optimizer_data = block_ffm.optimizer_ffm.initial_data();
}
}

Expand Down
5 changes: 0 additions & 5 deletions src/regressor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ pub trait BlockTrait {
) -> Result<(), Box<dyn Error>> {
Ok(())
}

/// Sets internal state of weights based on some completely object-dependent parameters
fn testing_set_weights(&mut self, _index: usize, _w: &[f32]) -> Result<(), Box<dyn Error>> {
Ok(())
}
}

pub struct Regressor {
Expand Down

0 comments on commit c96961f

Please sign in to comment.