Skip to content

Unit testing for numerical applications in Rust.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

tamaskis/numtest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

numtest

github crates.io docs.rs

Unit testing for numerical applications in Rust.

Documentation

Please see https://docs.rs/numtest.

Examples

Float equality

use numtest::{
    assert_equal, assert_equal_to_decimal, assert_equal_to_atol, assert_equal_to_rtol, Compare
};

assert_equal!(2.0, 2.0);
assert_equal_to_decimal!(2.0, 2.012, 1);
assert_equal_to_atol!(2.0, 2.00001, 1e-3);
assert_equal_to_rtol!(2.0, 2.01, 0.01);

Array equality

use numtest::{assert_arrays_equal, Compare};

let arr1 = [1.1, 2.2, 3.3];
let arr2 = [1.1, 2.2, 3.3];

assert_arrays_equal!(&arr1, &arr2);
use numtest::{assert_arrays_equal_to_decimal, Compare};

let arr1 = [1.1, 2.2, 3.3];
let arr2 = [1.1, 2.22, 3.33];

assert_arrays_equal_to_decimal!(&arr1, &arr2, 1);
use nalgebra::Vector3;
use ndarray::Array1;
use numtest::{
    assert_arrays_equal_to_atol, assert_arrays_equal_to_decimal, assert_arrays_equal_to_rtol,
    Compare,
};

let std_arr = [1.1, 2.2, 3.3];
let std_vec = vec![1.1, 2.22, 3.33];
let ndarray_arr = Array1::from_vec(vec![1.12, 2.23, 3.34]);
let nalgebra_vec = Vector3::new(1.13, 2.24, 3.35);

assert_arrays_equal_to_decimal!(&std_arr, &std_vec, 1);
assert_arrays_equal_to_atol!(&std_arr, &ndarray_arr, 0.06);
assert_arrays_equal_to_rtol!(&std_arr, &nalgebra_vec, 0.03);
use nalgebra::Matrix3;
use numtest::{assert_arrays_equal_to_decimal, Compare};

let mat1 = Matrix3::new(1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9);
let mat2 = Matrix3::new(1.1, 2.22, 3.33, 4.4, 5.55, 6.66, 7.7, 8.88, 9.99);

assert_arrays_equal_to_decimal!(&mat1, &mat2, 1);

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Unit testing for numerical applications in Rust.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published