diff --git a/src/function_entry.rs b/src/function_entry.rs index 3399f21..019cd9c 100644 --- a/src/function_entry.rs +++ b/src/function_entry.rs @@ -271,9 +271,9 @@ impl FunctionEntry { return; } - let step = (settings.plot_width as f64) / (settings.max_x - settings.min_x); - debug_assert!(step > 0.0); - let resolution_iter = resolution_helper(&settings.plot_width + 1, &settings.min_x, &step); + let resolution = (settings.max_x - settings.min_x) / (settings.plot_width as f64); + debug_assert!(resolution > 0.0); + let resolution_iter = step_helper(&settings.plot_width + 1, &settings.min_x, &resolution); unsafe { assume(!resolution_iter.is_empty()) } @@ -410,7 +410,7 @@ impl FunctionEntry { self.invalidate_integral(); } - let threshold: f64 = step / 2.0; + let threshold: f64 = resolution / 2.0; let x_range = settings.min_x..settings.max_x; // Calculates extrema diff --git a/src/lib.rs b/src/lib.rs index b91fa8c..2c003ed 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,7 +32,6 @@ pub use crate::{ hashed_storage_create, hashed_storage_read, option_vec_printer, - resolution_helper, step_helper, SteppedVector, }, diff --git a/src/misc.rs b/src/misc.rs index dc442d1..9ee63e1 100644 --- a/src/misc.rs +++ b/src/misc.rs @@ -299,13 +299,6 @@ where .concat() } -/// Returns a vector of length `max_i` starting at value `min_x` with resolution of `resolution` -pub fn resolution_helper(max_i: usize, min_x: &f64, resolution: &f64) -> Vec { - (0..max_i) - .map(|x| (x as f64 / resolution) + min_x) - .collect() -} - /// Returns a vector of length `max_i` starting at value `min_x` with step of `step` pub fn step_helper(max_i: usize, min_x: &f64, step: &f64) -> Vec { (0..max_i).map(|x| (x as f64 * step) + min_x).collect() diff --git a/tests/misc.rs b/tests/misc.rs index 8afc81f..913d289 100644 --- a/tests/misc.rs +++ b/tests/misc.rs @@ -48,22 +48,6 @@ fn stepped_vector() { // } /// Tests [`resolution_helper`] to make sure it returns expected output -#[test] -fn resolution_helper() { - use ytbn_graphing_software::resolution_helper; - - assert_eq!( - resolution_helper(10, &1.0, &1.0), - vec![1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] - ); - - assert_eq!( - resolution_helper(5, &-2.0, &1.0), - vec![-2.0, -1.0, 0.0, 1.0, 2.0] - ); - - assert_eq!(resolution_helper(3, &-2.0, &1.0), vec![-2.0, -1.0, 0.0]); -} #[test] fn step_helper() {