made some field private

This commit is contained in:
Daniel Bauer
2018-10-08 23:02:50 +02:00
parent 88d9146911
commit 35e0fbf065
2 changed files with 16 additions and 17 deletions

View File

@@ -5,16 +5,16 @@ use std::cell::RefCell;
#[derive(Debug)] #[derive(Debug)]
pub struct Histogram { pub struct Histogram {
// offset of this histogram bins from the global histogram // offset of this histogram bins from the global histogram
pub first: usize, first: usize,
// offset of the last element of the histogram. TODO required? // offset of the last element of the histogram. TODO required?
pub last: usize, last: usize,
// total number of data points stored in the histogram // total number of data points stored in the histogram
pub num_points: u32, pub num_points: u32,
// histogram bins // histogram bins
pub bins: Vec<f64> bins: Vec<f64>
} }
impl Histogram { impl Histogram {
@@ -44,13 +44,13 @@ pub struct Dataset {
pub num_bins: usize, pub num_bins: usize,
// min value of the histogram // min value of the histogram
pub hist_min: f64, hist_min: f64,
// max value of the histogram // max value of the histogram
pub hist_max: f64, hist_max: f64,
// width of a bin in unit of x // width of a bin in unit of x
pub bin_width: f64, bin_width: f64,
// value of kT // value of kT
pub kT: f64, pub kT: f64,

View File

@@ -170,13 +170,12 @@ mod tests {
let cfg = cfg(); let cfg = cfg();
let h = super::read_window_file(&f, &cfg).unwrap(); let h = super::read_window_file(&f, &cfg).unwrap();
println!("{:?}", h); println!("{:?}", h);
assert_eq!(1, h.first); // assert_eq!(1, h.first);
assert_eq!(6, h.last); // assert_eq!(6, h.last);
assert_eq!(11, h.num_points); assert_eq!(11, h.num_points);
assert_eq!(2.0, h.bins[0]); assert_eq!(2.0, h.get_bin_count(1).unwrap());
assert_eq!(2.0, h.bins[2]); assert_eq!(2.0, h.get_bin_count(2).unwrap());
assert_eq!(2.0, h.bins[4]); assert_eq!(1.0, h.get_bin_count(6).unwrap());
assert_eq!(1.0, h.bins[5]);
} }
@@ -189,11 +188,11 @@ mod tests {
println!("{:?}", ds); println!("{:?}", ds);
assert_eq!(2, ds.num_windows); assert_eq!(2, ds.num_windows);
assert_eq!(cfg.num_bins, ds.num_bins); assert_eq!(cfg.num_bins, ds.num_bins);
assert_eq!(cfg.hist_min, ds.hist_min); // fields are private
assert_eq!(cfg.hist_max, ds.hist_max); // assert_eq!(cfg.hist_min, ds.hist_min);
let expected_bin_width = (cfg.hist_max - cfg.hist_min)/cfg.num_bins as f64; // assert_eq!(cfg.hist_max, ds.hist_max);
assert_eq!(expected_bin_width, ds.bin_width); // let expected_bin_width = (cfg.hist_max - cfg.hist_min)/cfg.num_bins as f64;
// bias fields are private // assert_eq!(expected_bin_width, ds.bin_width);
// assert_eq!(vec![0.0, 1.0], ds.bias_x0); // assert_eq!(vec![0.0, 1.0], ds.bias_x0);
// assert_eq!(vec![100.0, 200.0], ds.bias_fc); // assert_eq!(vec![100.0, 200.0], ds.bias_fc);
assert_eq!(cfg.temperature * k_B, ds.kT); assert_eq!(cfg.temperature * k_B, ds.kT);