# numpy.testing.assert_allclose

testing.assert_allclose(actual, desired, rtol=1e-07, atol=0, equal_nan=True, err_msg='', verbose=True)

  Raises an AssertionError if two objects are not equal up to desired tolerance.

  Given two array_like objects, check that their shapes and all elements are equal (but see the Notes for the special handling of a scalar). An exception is raised if the shapes mismatch or any values conflict. In contrast to the standard usage in numpy, NaNs are compared like numbers, no assertion is raised if both objects have NaNs in the same positions.

  The test is equivalent to `allclose(actual, desired, rtol, atol)` (note that `allclose` has different default values). It compares the difference between actual and desired to `atol + rtol * abs(desired)`.

  New in version 1.5.0.

  Parameters:
    actual array_like

      Array obtained.

    desired array_like

      Array desired.

    rtol float, optional

      Relative tolerance.

    atol float, optional

      Absolute tolerance.

    equal_nan bool, optional.

      If True, NaNs will compare equal.

    err_msg str, optional

      The error message to be printed in case of failure.

    verbose bool, optional

      If True, the conflicting values are appended to the error message.

  Raises:
    AssertionError

      If actual and desired are not equal up to specified precision.

  See also

  `assert_array_almost_equal_nulp`, `assert_array_max_ulp`

  Notes

  When one of actual and desired is a scalar and the other is array_like, the function checks that each element of the array_like object is equal to the scalar.

  Examples

      >>> x = [1e-5, 1e-3, 1e-1]
      >>> y = np.arccos(np.cos(x))
      >>> np.testing.assert_allclose(x, y, rtol=1e-5, atol=0)