cleanup
This commit is contained in:
parent
74be8357cf
commit
90cd4e81df
@ -525,17 +525,16 @@ impl epi::App for MathApp {
|
|||||||
|
|
||||||
if let Some(bars_data) = bars {
|
if let Some(bars_data) = bars {
|
||||||
let (integral_bar, integral_line, area) = bars_data;
|
let (integral_bar, integral_line, area) = bars_data;
|
||||||
|
let integral_name = format!("Integral of {}", func_str);
|
||||||
match self.settings.integral_display_type {
|
match self.settings.integral_display_type {
|
||||||
IntegralDisplay::Rectangles => plot_ui.bar_chart(
|
IntegralDisplay::Rectangles => plot_ui.bar_chart(
|
||||||
integral_bar
|
integral_bar
|
||||||
.color(Color32::BLUE)
|
.color(Color32::BLUE)
|
||||||
.width(step)
|
.width(step)
|
||||||
.name(format!("Integral of {}", func_str)),
|
.name(integral_name),
|
||||||
),
|
),
|
||||||
IntegralDisplay::Line => plot_ui.line(
|
IntegralDisplay::Line => plot_ui.line(
|
||||||
integral_line
|
integral_line.color(Color32::BLUE).name(integral_name),
|
||||||
.color(Color32::BLUE)
|
|
||||||
.name(format!("Integral of {}", func_str)),
|
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
digits_precision(area, 8)
|
digits_precision(area, 8)
|
||||||
|
|||||||
@ -377,9 +377,7 @@ fn left_function_test() {
|
|||||||
assert_eq!(bars.clone().unwrap().2, area_target);
|
assert_eq!(bars.clone().unwrap().2, area_target);
|
||||||
let bars_unwrapped = bars.unwrap();
|
let bars_unwrapped = bars.unwrap();
|
||||||
|
|
||||||
let vec_bars: Vec<f64> = bars_unwrapped.0.iter().map(|bar| bar.value).collect();
|
assert_eq!(bars_unwrapped.0.iter().len(), integral_num);
|
||||||
|
|
||||||
assert_eq!(vec_bars.len(), integral_num);
|
|
||||||
|
|
||||||
let integral_line = bars_unwrapped.1;
|
let integral_line = bars_unwrapped.1;
|
||||||
let vec_integral: Vec<(f64, f64)> =
|
let vec_integral: Vec<(f64, f64)> =
|
||||||
@ -453,9 +451,7 @@ fn middle_function_test() {
|
|||||||
assert_eq!(bars.clone().unwrap().2, area_target);
|
assert_eq!(bars.clone().unwrap().2, area_target);
|
||||||
let bars_unwrapped = bars.unwrap();
|
let bars_unwrapped = bars.unwrap();
|
||||||
|
|
||||||
let vec_bars: Vec<f64> = bars_unwrapped.0.iter().map(|bar| bar.value).collect();
|
assert_eq!(bars_unwrapped.0.iter().len(), integral_num);
|
||||||
|
|
||||||
assert_eq!(vec_bars.len(), integral_num);
|
|
||||||
|
|
||||||
let integral_line = bars_unwrapped.1;
|
let integral_line = bars_unwrapped.1;
|
||||||
let vec_integral: Vec<(f64, f64)> =
|
let vec_integral: Vec<(f64, f64)> =
|
||||||
@ -529,9 +525,7 @@ fn right_function_test() {
|
|||||||
assert_eq!(bars.clone().unwrap().2, area_target);
|
assert_eq!(bars.clone().unwrap().2, area_target);
|
||||||
let bars_unwrapped = bars.unwrap();
|
let bars_unwrapped = bars.unwrap();
|
||||||
|
|
||||||
let vec_bars: Vec<f64> = bars_unwrapped.0.iter().map(|bar| bar.value).collect();
|
assert_eq!(bars_unwrapped.0.iter().len(), integral_num);
|
||||||
|
|
||||||
assert_eq!(vec_bars.len(), integral_num);
|
|
||||||
|
|
||||||
let integral_line = bars_unwrapped.1;
|
let integral_line = bars_unwrapped.1;
|
||||||
let vec_integral: Vec<(f64, f64)> =
|
let vec_integral: Vec<(f64, f64)> =
|
||||||
|
|||||||
@ -5,8 +5,6 @@ mod egui_app;
|
|||||||
mod function;
|
mod function;
|
||||||
mod misc;
|
mod misc;
|
||||||
mod parsing;
|
mod parsing;
|
||||||
#[macro_use]
|
|
||||||
extern crate lazy_static;
|
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(target_arch = "wasm32")] {
|
||||||
|
|||||||
@ -9,7 +9,7 @@ pub struct BackingFunction {
|
|||||||
impl BackingFunction {
|
impl BackingFunction {
|
||||||
pub fn new(func_str: &str) -> Self {
|
pub fn new(func_str: &str) -> Self {
|
||||||
let function = exmex::parse::<f64>(func_str).unwrap();
|
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());
|
// let derivative_2 = function.partial(0).unwrap_or(derivative_1.clone());
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user