Crates.io | nikisas_test |
lib.rs | nikisas_test |
version | 0.1.0 |
source | src |
created_at | 2020-09-25 15:16:25.327907 |
updated_at | 2020-09-25 15:16:25.327907 |
description | Utilities for testing implementation quality of mathematical functions. Computing errors for inputs randomly sampled from given interval. |
homepage | https://crates.io/crates/nikisas_test |
repository | https://github.com/pnevyk/nikisas_test |
max_upload_size | |
id | 292859 |
size | 34,127 |
Utilities for testing implementation quality of mathematical functions. Computing errors for inputs randomly sampled from given interval.
To determine the errors:
use nikisas_test::prelude::*;
fn exp(x: f32) -> f32 {
// your implementation
# 0.0
}
// Uniformly sample 100000 values from -87.3 to 88.7.
UniformSample::with_count(-87.3, 88.7, 100000)
// Use implementation from the standard library as ground truth.
.error(|x| (exp(x), x.exp()))
// Print the errors to standard output.
.print_plain("exp");
To ensure desired error bounds:
use nikisas_test::prelude::*;
// Uniformly sample 100000 values from -87.3 to 88.7.
UniformSample::with_count(-87.3, 88.7, 100000)
// Use implementation from the standard library as ground truth.
// If eny specified error bound is violated, the program panics with a readable message.
.assert(ErrorBounds::new().rel(0.001).abs(0.0001), |x| (exp(x), x.exp()));
See documentation on crates.io.
nikisas_test is licensed under MIT. Feel free to use it, contribute or spread the word.