Assertions#

ivy_tests.test_ivy.helpers.assertions.assert_all_close(ret_np, ret_from_gt_np, backend, rtol=1e-05, atol=1e-08, ground_truth_backend='TensorFlow')[source]#

Match the ret_np and ret_from_gt_np inputs element-by-element to ensure that they are the same.

Parameters:
  • ret_np – Return from the framework to test. Ivy Container or Numpy Array.

  • ret_from_gt_np – Return from the ground truth framework. Ivy Container or Numpy Array.

  • rtol (default: 1e-05) – Relative Tolerance Value.

  • atol (default: 1e-08) – Absolute Tolerance Value.

  • ground_truth_backend (default: 'TensorFlow') – Ground Truth Backend Framework.

Returns:

None if the test passes, else marks the test as failed.

ivy_tests.test_ivy.helpers.assertions.assert_same_type(ret_from_target, ret_from_gt, backend_to_test, gt_backend)[source]#

Assert that the return types from the target and ground truth frameworks are the same.

checks with a string comparison because with_backend returns different objects. Doesn’t check recursively.

ivy_tests.test_ivy.helpers.assertions.assert_same_type_and_shape(values, this_key_chain=None)[source]#
ivy_tests.test_ivy.helpers.assertions.check_unsupported_device(*, fn, input_device, all_as_kwargs_np)[source]#

Check whether a function does not support a given device.

Parameters:
  • fn – The function to check.

  • input_device – The backend device.

  • all_as_kwargs_np – All arguments in Numpy Format, to check for the presence of dtype argument.

Returns:

True if the function does not support the given device, False otherwise.

ivy_tests.test_ivy.helpers.assertions.check_unsupported_device_and_dtype(*, fn, device, input_dtypes, all_as_kwargs_np)[source]#

Check whether a function does not support a given device or data types.

Parameters:
  • fn – The function to check.

  • device – The backend device to check.

  • input_dtypes – data-types of the input arguments and keyword-arguments.

  • all_as_kwargs_np – All arguments in Numpy Format, to check for the presence of dtype argument.

Returns:

  • True if the function does not support both the device and any data type, False

  • otherwise.

ivy_tests.test_ivy.helpers.assertions.check_unsupported_dtype(*, fn, input_dtypes, all_as_kwargs_np)[source]#

Check whether a function does not support the input data types or the output data type.

Parameters:
  • fn – The function to check.

  • input_dtypes – data-types of the input arguments and keyword-arguments.

  • all_as_kwargs_np – All arguments in Numpy Format, to check for the presence of dtype argument.

Returns:

  • True if the function does not support the given input or output data types, False

  • otherwise.

ivy_tests.test_ivy.helpers.assertions.test_unsupported_function(*, fn, args, kwargs)[source]#

Test a function with an unsupported datatype to raise an exception.

Parameters:
  • fn – callable function to test.

  • args – arguments to the function.

  • kwargs – keyword-arguments to the function.

ivy_tests.test_ivy.helpers.assertions.value_test(*, ret_np_flat, ret_np_from_gt_flat, rtol=None, atol=1e-06, specific_tolerance_dict=None, backend, ground_truth_backend='TensorFlow')[source]#

Perform a value test for matching the arrays in ret_np_flat and ret_from_np_gt_flat.

Parameters:
  • ret_np_flat – A list (flattened) containing Numpy arrays. Return from the framework to test.

  • ret_np_from_gt_flat – A list (flattened) containing Numpy arrays. Return from the ground truth framework.

  • rtol (default: None) – Relative Tolerance Value.

  • atol (default: 1e-06) – Absolute Tolerance Value.

  • specific_tolerance_dict (default: None) – (Optional) Dictionary of specific rtol and atol values according to the dtype.

  • ground_truth_backend (default: 'TensorFlow') – Ground Truth Backend Framework.

Returns:

None if the value test passes, else marks the test as failed.

This should have hopefully given you an overview of the assertions submodule, if you have any questions, please feel free to reach out on our discord!