assert_y

Macro assert_y 

Source
macro_rules! assert_y {
    ($function:expr, $x:expr, $expected:expr $(, $msg:literal $(, $($args:tt),*)?)?) => { ... };
}
Expand description

Asserts that evaluating a polynomial at a given x matches the expected y value within floating-point epsilon tolerance.

Useful for spot-checking specific predictions of the model.

§Arguments

  • $function - The polynomial under test (must implement AsRef<Polynomial<...>>).
  • $x - The input x value where the polynomial is evaluated.
  • $expected - The expected result of the polynomial evaluation.

§Panics

Panics if the evaluated value differs from the expected value by more than machine epsilon for the type T.

§Example

use polyfit::{function, assert_y};

function!(test(x) = 8.0 + 7.0 x^1 + 6.0 x^2);

// 8 + 7*2 + 6*4 = 8 + 14 + 24 = 46
assert_y!(test, 2.0, 46.0);