testing

Module

Implements various testing utils.

You can import these APIs from the testing package. For example:

from testing import assert_true

assert_true

assert_true(val: object, msg: String)

Asserts that the input value is True. If it is not then an Error is raised.

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

Args:

  • ​val (object): The value to assert to be True.
  • ​msg (String): The message to be printed if the assertion fails.

assert_true(val: Bool, msg: String)

Asserts that the input value is True. If it is not then an Error is raised.

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

Args:

  • ​val (Bool): The value to assert to be True.
  • ​msg (String): The message to be printed if the assertion fails.

assert_false

assert_false(val: object, msg: String)

Asserts that the input value is False. If it is not then an Error is raised.

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

Args:

  • ​val (object): The value to assert to be False.
  • ​msg (String): The message to be printed if the assertion fails.

assert_false(val: Bool, msg: String)

Asserts that the input value is False. If it is not then an Error is raised.

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

Args:

  • ​val (Bool): The value to assert to be False.
  • ​msg (String): The message to be printed if the assertion fails.

assert_equal

assert_equal(lhs: Int, rhs: Int)

Asserts that the input values are equal. If it is not then an Error is raised.

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

Args:

  • ​lhs (Int): The lhs of the equality.
  • ​rhs (Int): The rhs of the equality.

assert_equal(lhs: String, rhs: String)

Asserts that the input values are equal. If it is not then an Error is raised.

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

Args:

  • ​lhs (String): The lhs of the equality.
  • ​rhs (String): The rhs of the equality.

assert_equal[type: DType, size: Int](lhs: SIMD[type, size], rhs: SIMD[type, size])

Asserts that the input values are equal. If it is not then an Error is raised.

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

Parameters:

  • ​type (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[type, size]): The lhs of the equality.
  • ​rhs (SIMD[type, size]): The rhs of the equality.

assert_not_equal

assert_not_equal(lhs: Int, rhs: Int)

Asserts that the input values are not equal. If it is not then an Error is raised.

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

Args:

  • ​lhs (Int): The lhs of the inequality.
  • ​rhs (Int): The rhs of the inequality.

assert_not_equal(lhs: String, rhs: String)

Asserts that the input values are not equal. If it is not then an an Error is raised.

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

Args:

  • ​lhs (String): The lhs of the inequality.
  • ​rhs (String): The rhs of the inequality.

assert_not_equal[type: DType, size: Int](lhs: SIMD[type, size], rhs: SIMD[type, size])

Asserts that the input values are not equal. If it is not then an Error is raised.

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

Parameters:

  • ​type (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[type, size]): The lhs of the inequality.
  • ​rhs (SIMD[type, size]): The rhs of the inequality.

assert_almost_equal

assert_almost_equal[type: DType, size: Int](lhs: SIMD[type, size], rhs: SIMD[type, size], absolute_tolerance: SIMD[type, 1], relative_tolerance: SIMD[type, 1])

Asserts that the input values are equal up to a tolerance. If it is not then an Error is raised.

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

Parameters:

  • ​type (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[type, size]): The lhs of the equality.
  • ​rhs (SIMD[type, size]): The rhs of the equality.
  • ​absolute_tolerance (SIMD[type, 1]): The absolute tolerance.
  • ​relative_tolerance (SIMD[type, 1]): The relative tolerance.