Mojo function
assert_almost_equal
assert_almost_equal[dtype: DType, size: Int](lhs: SIMD[dtype, size], rhs: SIMD[dtype, size], msg: String = __init__[__mlir_type.!kgen.string](""), *, atol: SIMD[float64, 1] = __init__[__mlir_type.!pop.float_literal](1.0E-8), rtol: SIMD[float64, 1] = __init__[__mlir_type.!pop.float_literal](1.0000000000000001E-5), equal_nan: Bool = False, location: Optional[_SourceLocation] = Optional(None))
Asserts that the input values are equal up to a tolerance. If it is not then an Error is raised.
When the type is boolean or integral, then equality is checked. When the type is floating-point, then this checks if the two input values are numerically the close using the formula.
Constraints:
The type must be boolean, integral, or floating-point.
Parameters:
- dtype (
DType
): The dtype of the left- and right-hand-side SIMD vectors. - size (
Int
): The width of the left- and right-hand-side SIMD vectors.
Args:
- lhs (
SIMD[dtype, size]
): The lhs of the equality. - rhs (
SIMD[dtype, size]
): The rhs of the equality. - msg (
String
): The message to print. - atol (
SIMD[float64, 1]
): The absolute tolerance. - rtol (
SIMD[float64, 1]
): The relative tolerance. - equal_nan (
Bool
): Whether to treat nans as equal. - location (
Optional[_SourceLocation]
): The location of the error (defaults to__call_location
).
Raises:
An Error with the provided message if assert fails and None
otherwise.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!