From b08098d0a4953be3ec04dc6fc24ab2310f539849 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Tue, 22 Oct 2024 14:50:40 -0600 Subject: [PATCH 1/2] Fix an incorrect usage of cmath --- array_api_tests/test_operators_and_elementwise_functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/array_api_tests/test_operators_and_elementwise_functions.py b/array_api_tests/test_operators_and_elementwise_functions.py index 785d3665..c9bca47f 100644 --- a/array_api_tests/test_operators_and_elementwise_functions.py +++ b/array_api_tests/test_operators_and_elementwise_functions.py @@ -72,9 +72,9 @@ def isclose_complex( if cmath.isnan(a) or cmath.isnan(b): raise ValueError(f"{a=} and {b=}, but input must be non-NaN") if cmath.isinf(a): - return cmath.isinf(b) or abs(b) > cmath.log(maximum) + return cmath.isinf(b) or abs(b) > math.log(maximum) elif cmath.isinf(b): - return cmath.isinf(a) or abs(a) > cmath.log(maximum) + return cmath.isinf(a) or abs(a) > math.log(maximum) return cmath.isclose(a, b, rel_tol=rel_tol, abs_tol=abs_tol) From d1176f512e08acb895d10086cb2cfe5ef22705d9 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Fri, 25 Oct 2024 13:06:45 -0600 Subject: [PATCH 2/2] Use a more reasonable test for a large float --- array_api_tests/test_operators_and_elementwise_functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/array_api_tests/test_operators_and_elementwise_functions.py b/array_api_tests/test_operators_and_elementwise_functions.py index c9bca47f..f14c7585 100644 --- a/array_api_tests/test_operators_and_elementwise_functions.py +++ b/array_api_tests/test_operators_and_elementwise_functions.py @@ -72,9 +72,9 @@ def isclose_complex( if cmath.isnan(a) or cmath.isnan(b): raise ValueError(f"{a=} and {b=}, but input must be non-NaN") if cmath.isinf(a): - return cmath.isinf(b) or abs(b) > math.log(maximum) + return cmath.isinf(b) or abs(b) > 2**(math.log2(maximum)//2) elif cmath.isinf(b): - return cmath.isinf(a) or abs(a) > math.log(maximum) + return cmath.isinf(a) or abs(a) > 2**(math.log2(maximum)//2) return cmath.isclose(a, b, rel_tol=rel_tol, abs_tol=abs_tol)