macro_rules! assert_fits {
($canonical:expr, $fit:expr, $r2:expr $(, $msg:literal $(, $($args:tt),*)?)?) => { ... };
($canonical:expr, $fit:expr) => { ... };
}Expand description
Asserts that the fitted curve is a good representation of a canonical curve. Compares the fit’s r² value against a threshold to ensure it closely follows the expected curve.
Useful if you know the underlying function but want to validate the fitting process.
If the test fails, a plot showing both curves will be generated in <target/test_output>
The plot will also include the original source data, as well as 99% confidence error bars for the fit.
See crate::CurveFit::r_squared for more details.
Threshold for r² match can be specified, or defaults to 0.9.
If you add noise to the data you generated, the noise strength should correspond to the r² threshold
§Example plot

function!(test(x) = 20.0 + 3.0 x^1 + 2.0 x^2 + 4.0 x^3 );
let data = test.solve_range(0.0..=1000.0, 1.0).apply_normal_noise(Strength::Relative(0.1), None);
let fit = ChebyshevFit::new_auto(&data, DegreeBound::Relaxed, &Aic).expect("Failed to create model");
assert_fits!(&test, &fit, 0.9);