IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0.0b1
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

assert_almost_equal

assert_almost_equal[dtype: DType, size: Int](lhs: SIMD[dtype, size], rhs: SIMD[dtype, size], msg: String = "", *, atol: Float64 = 1.0E-8, rtol: Float64 = 1.0000000000000001E-5, equal_nan: Bool = False, location: Optional[SourceLocation] = 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 abs(lhsrhs)<=max(rtolmax(abs(lhs),abs(rhs)),atol)abs(lhs - rhs) <= max(rtol * max(abs(lhs), abs(rhs)), atol) 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:

Raises:

An Error with the provided message if assert fails and None otherwise.