From 2d1d3a60d1ce54a0a445453450f46ab998bab75d Mon Sep 17 00:00:00 2001 From: Sachin Krishnan T V Date: Mon, 23 May 2022 17:29:26 +0200 Subject: Improve docstring of numpy.testing.assert_allclose --- numpy/testing/_private/utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'numpy') diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index 4a8f42e06..656afcb9c 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -1476,6 +1476,13 @@ 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 the shape is equal and all + elements of these objects are equal (but see the Notes for the special + handling of a scalar). An exception is raised at shape mismatch or + conflicting values. 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 +1515,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] -- cgit v1.2.1 From 4e70f09a4f2679a973f36a666ef4249f465af2d4 Mon Sep 17 00:00:00 2001 From: Sachin Krishnan T V Date: Mon, 23 May 2022 19:39:14 +0200 Subject: Make double backticks for parameters in docstring --- numpy/testing/_private/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy') diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index 656afcb9c..c44815d8c 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -1517,7 +1517,7 @@ def assert_allclose(actual, desired, rtol=1e-7, atol=0, equal_nan=True, Notes ----- - When one of `actual` and `desired` is a scalar and the other is array_like, + 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. -- cgit v1.2.1 From b1730f72a647a56a43e109613bf74238fdcb9983 Mon Sep 17 00:00:00 2001 From: Sachin Krishnan T V Date: Mon, 23 May 2022 19:46:39 +0200 Subject: Break lines in comments to follow line length limits --- numpy/testing/_private/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'numpy') diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index c44815d8c..e85eda3d7 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -1517,9 +1517,9 @@ def assert_allclose(actual, desired, rtol=1e-7, atol=0, equal_nan=True, 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. + 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 -------- -- cgit v1.2.1 From fad2c4d391d6a14a01ef9fc17c45cdf011164992 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Tue, 7 Jun 2022 08:53:35 -0600 Subject: STY: Use single backticks around parameter names. --- numpy/testing/_private/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy') diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index e85eda3d7..e61e47488 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -1517,7 +1517,7 @@ def assert_allclose(actual, desired, rtol=1e-7, atol=0, equal_nan=True, Notes ----- - When one of ``actual`` and ``desired`` is a scalar and the other is + 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. -- cgit v1.2.1 From 96a15a2d86eabcbbb47374d87f804404d3a08dbf Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Tue, 7 Jun 2022 10:01:23 -0600 Subject: MAINT: Small rewrite for clarity. --- numpy/testing/_private/utils.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'numpy') diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index e61e47488..e4f8b9892 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -1476,12 +1476,11 @@ 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 the shape is equal and all - elements of these objects are equal (but see the Notes for the special - handling of a scalar). An exception is raised at shape mismatch or - conflicting values. 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. + 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 -- cgit v1.2.1