changes from my egui fork

This commit is contained in:
Simon Gardling 2022-05-13 14:13:19 -04:00
parent 2d63c1b5f7
commit e2c2713633
6 changed files with 43 additions and 35 deletions

2
.gitignore vendored
View File

@ -2,3 +2,5 @@
/pkg
/tmp
/Cargo.lock
perf.data
flamegraph.svg

18
Cargo.lock generated
View File

@ -662,7 +662,7 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
[[package]]
name = "eframe"
version = "0.18.0"
source = "git+https://github.com/Titaniumtown/egui.git#1797df1670ae95b5da81fb99324531f6737826e9"
source = "git+https://github.com/Titaniumtown/egui.git#63980778541f105b139e6db0095c10a0f2ce4ad1"
dependencies = [
"bytemuck",
"egui",
@ -682,7 +682,7 @@ dependencies = [
[[package]]
name = "egui"
version = "0.18.1"
source = "git+https://github.com/Titaniumtown/egui.git#1797df1670ae95b5da81fb99324531f6737826e9"
source = "git+https://github.com/Titaniumtown/egui.git#63980778541f105b139e6db0095c10a0f2ce4ad1"
dependencies = [
"ahash",
"epaint",
@ -693,7 +693,7 @@ dependencies = [
[[package]]
name = "egui-winit"
version = "0.18.0"
source = "git+https://github.com/Titaniumtown/egui.git#1797df1670ae95b5da81fb99324531f6737826e9"
source = "git+https://github.com/Titaniumtown/egui.git#63980778541f105b139e6db0095c10a0f2ce4ad1"
dependencies = [
"arboard",
"egui",
@ -706,7 +706,7 @@ dependencies = [
[[package]]
name = "egui_glow"
version = "0.18.1"
source = "git+https://github.com/Titaniumtown/egui.git#1797df1670ae95b5da81fb99324531f6737826e9"
source = "git+https://github.com/Titaniumtown/egui.git#63980778541f105b139e6db0095c10a0f2ce4ad1"
dependencies = [
"bytemuck",
"egui",
@ -726,7 +726,7 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "emath"
version = "0.18.0"
source = "git+https://github.com/Titaniumtown/egui.git#1797df1670ae95b5da81fb99324531f6737826e9"
source = "git+https://github.com/Titaniumtown/egui.git#63980778541f105b139e6db0095c10a0f2ce4ad1"
dependencies = [
"bytemuck",
"libm",
@ -736,7 +736,7 @@ dependencies = [
[[package]]
name = "epaint"
version = "0.18.1"
source = "git+https://github.com/Titaniumtown/egui.git#1797df1670ae95b5da81fb99324531f6737826e9"
source = "git+https://github.com/Titaniumtown/egui.git#63980778541f105b139e6db0095c10a0f2ce4ad1"
dependencies = [
"ab_glyph",
"ahash",
@ -1845,9 +1845,9 @@ dependencies = [
[[package]]
name = "rayon-core"
version = "1.9.2"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f51245e1e62e1f1629cbfec37b5793bbabcaeb90f30e94d2ba03564687353e4"
checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f"
dependencies = [
"crossbeam-channel",
"crossbeam-deque",
@ -1923,7 +1923,7 @@ dependencies = [
[[package]]
name = "ruzstd"
version = "0.2.4"
source = "git+https://github.com/Titaniumtown/zstd-rs.git?branch=ringbuffer#1b2f128459f6a899788465bc005d75f0240c9eae"
source = "git+https://github.com/Titaniumtown/zstd-rs.git?branch=ringbuffer#56972fa1fe8b188ad2f1f54fe1fe35d9479a2d9f"
dependencies = [
"byteorder",
"twox-hash",

View File

@ -531,7 +531,7 @@ impl FunctionEntry {
}
// return value rounded to 8 decimal places
Some(crate::misc::decimal_round(integral_data.1, 8))
Some(emath::round_to_decimals(integral_data.1, 8))
}
_ => None,
}

View File

@ -28,8 +28,14 @@ pub use crate::{
function_entry::{FunctionEntry, Riemann},
math_app::AppSettings,
misc::{
decimal_round, format_bytes, hashed_storage_create, hashed_storage_read,
option_vec_printer, resolution_helper, step_helper, SteppedVector,
// decimal_round,
format_bytes,
hashed_storage_create,
hashed_storage_read,
option_vec_printer,
resolution_helper,
step_helper,
SteppedVector,
},
};

View File

@ -188,13 +188,13 @@ impl EguiHelper for Vec<Value> {
fn to_tuple(&self) -> Vec<(f64, f64)> { self.iter().map(|ele| (ele.x, ele.y)).collect() }
}
/// Rounds f64 to `n` decimal places
pub fn decimal_round(x: f64, n: usize) -> f64 {
let large_number: f64 = 10.0_f64.powf(n as f64); // 10^n
// /// Rounds f64 to `n` decimal places
// pub fn decimal_round(x: f64, n: usize) -> f64 {
// let large_number: f64 = 10.0_f64.powf(n as f64); // 10^n
// round and devide in order to cutoff after the `n`th decimal place
(x * large_number).round() / large_number
}
// // round and devide in order to cutoff after the `n`th decimal place
// (x * large_number).round() / large_number
// }
/// Helper that assists with using newton's method of finding roots, iterating over data `data`
/// `threshold` is the target accuracy threshold

View File

@ -26,26 +26,26 @@ fn stepped_vector() {
assert_eq!(stepped_vector.get_index((max + 1) as f64), None);
}
/// Ensures [`decimal_round`] returns correct values
#[test]
fn decimal_round() {
use ytbn_graphing_software::decimal_round;
// /// Ensures [`decimal_round`] returns correct values
// #[test]
// fn decimal_round() {
// use ytbn_graphing_software::decimal_round;
assert_eq!(decimal_round(0.00001, 1), 0.0);
assert_eq!(decimal_round(0.00001, 2), 0.0);
assert_eq!(decimal_round(0.00001, 3), 0.0);
assert_eq!(decimal_round(0.00001, 4), 0.0);
assert_eq!(decimal_round(0.00001, 5), 0.00001);
// assert_eq!(decimal_round(0.00001, 1), 0.0);
// assert_eq!(decimal_round(0.00001, 2), 0.0);
// assert_eq!(decimal_round(0.00001, 3), 0.0);
// assert_eq!(decimal_round(0.00001, 4), 0.0);
// assert_eq!(decimal_round(0.00001, 5), 0.00001);
assert_eq!(decimal_round(0.12345, 1), 0.1);
assert_eq!(decimal_round(0.12345, 2), 0.12);
assert_eq!(decimal_round(0.12345, 3), 0.123);
assert_eq!(decimal_round(0.12345, 4), 0.1235); // rounds up
assert_eq!(decimal_round(0.12345, 5), 0.12345);
// assert_eq!(decimal_round(0.12345, 1), 0.1);
// assert_eq!(decimal_round(0.12345, 2), 0.12);
// assert_eq!(decimal_round(0.12345, 3), 0.123);
// assert_eq!(decimal_round(0.12345, 4), 0.1235); // rounds up
// assert_eq!(decimal_round(0.12345, 5), 0.12345);
assert_eq!(decimal_round(1.9, 0), 2.0);
assert_eq!(decimal_round(1.9, 1), 1.9);
}
// assert_eq!(decimal_round(1.9, 0), 2.0);
// assert_eq!(decimal_round(1.9, 1), 1.9);
// }
/// Tests [`resolution_helper`] to make sure it returns expected output
#[test]