This commit is contained in:
Simon Gardling 2022-03-08 08:48:45 -05:00
parent 74be8357cf
commit 90cd4e81df
4 changed files with 7 additions and 16 deletions

View File

@ -525,17 +525,16 @@ impl epi::App for MathApp {
if let Some(bars_data) = bars {
let (integral_bar, integral_line, area) = bars_data;
let integral_name = format!("Integral of {}", func_str);
match self.settings.integral_display_type {
IntegralDisplay::Rectangles => plot_ui.bar_chart(
integral_bar
.color(Color32::BLUE)
.width(step)
.name(format!("Integral of {}", func_str)),
.name(integral_name),
),
IntegralDisplay::Line => plot_ui.line(
integral_line
.color(Color32::BLUE)
.name(format!("Integral of {}", func_str)),
integral_line.color(Color32::BLUE).name(integral_name),
),
}
digits_precision(area, 8)

View File

@ -377,9 +377,7 @@ fn left_function_test() {
assert_eq!(bars.clone().unwrap().2, area_target);
let bars_unwrapped = bars.unwrap();
let vec_bars: Vec<f64> = bars_unwrapped.0.iter().map(|bar| bar.value).collect();
assert_eq!(vec_bars.len(), integral_num);
assert_eq!(bars_unwrapped.0.iter().len(), integral_num);
let integral_line = bars_unwrapped.1;
let vec_integral: Vec<(f64, f64)> =
@ -453,9 +451,7 @@ fn middle_function_test() {
assert_eq!(bars.clone().unwrap().2, area_target);
let bars_unwrapped = bars.unwrap();
let vec_bars: Vec<f64> = bars_unwrapped.0.iter().map(|bar| bar.value).collect();
assert_eq!(vec_bars.len(), integral_num);
assert_eq!(bars_unwrapped.0.iter().len(), integral_num);
let integral_line = bars_unwrapped.1;
let vec_integral: Vec<(f64, f64)> =
@ -529,9 +525,7 @@ fn right_function_test() {
assert_eq!(bars.clone().unwrap().2, area_target);
let bars_unwrapped = bars.unwrap();
let vec_bars: Vec<f64> = bars_unwrapped.0.iter().map(|bar| bar.value).collect();
assert_eq!(vec_bars.len(), integral_num);
assert_eq!(bars_unwrapped.0.iter().len(), integral_num);
let integral_line = bars_unwrapped.1;
let vec_integral: Vec<(f64, f64)> =

View File

@ -5,8 +5,6 @@ mod egui_app;
mod function;
mod misc;
mod parsing;
#[macro_use]
extern crate lazy_static;
cfg_if::cfg_if! {
if #[cfg(target_arch = "wasm32")] {

View File

@ -9,7 +9,7 @@ pub struct BackingFunction {
impl BackingFunction {
pub fn new(func_str: &str) -> Self {
let function = exmex::parse::<f64>(func_str).unwrap();
let derivative_1 = function.partial(0).unwrap_or(function.clone());
let derivative_1 = function.partial(0).unwrap_or_else(|_| function.clone());
// let derivative_2 = function.partial(0).unwrap_or(derivative_1.clone());
Self {