diff options
| author | Charles Harris <charlesr.harris@gmail.com> | 2022-06-07 10:02:15 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-07 10:02:15 -0600 |
| commit | 71d4fcc2fd39dcd9adaabce21a5b9ad3f7bba8cf (patch) | |
| tree | f9977835a06159cbb191c33bc9ff374653344cc0 /numpy | |
| parent | 15b92f7abc34dbae4d6ef881c8b4316961e47976 (diff) | |
| parent | 96a15a2d86eabcbbb47374d87f804404d3a08dbf (diff) | |
| download | numpy-71d4fcc2fd39dcd9adaabce21a5b9ad3f7bba8cf.tar.gz | |
Merge pull request #21579 from sachu92/doc-assert_allclose
DOC: Improve docstring of numpy.testing.assert_allclose
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/testing/_private/utils.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index 4a8f42e06..e4f8b9892 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -1476,6 +1476,12 @@ def assert_allclose(actual, desired, rtol=1e-7, atol=0, equal_nan=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)``. @@ -1508,6 +1514,12 @@ def assert_allclose(actual, desired, rtol=1e-7, atol=0, equal_nan=True, -------- 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] |
