Skip to content

Commit 5aa9083

Browse files
committed
Remove unused allclose and assert_allclose helpers
1 parent 6f9db94 commit 5aa9083

File tree

1 file changed

+0
-41
lines changed

1 file changed

+0
-41
lines changed

array_api_tests/array_helpers.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
from . import _array_module as xp
1111
from . import dtype_helpers as dh
1212

13-
from ndindex import iter_indices
14-
15-
import math
16-
1713
__all__ = ['all', 'any', 'logical_and', 'logical_or', 'logical_not', 'less',
1814
'less_equal', 'greater', 'subtract', 'negative', 'floor', 'ceil',
1915
'where', 'isfinite', 'equal', 'not_equal', 'zero', 'one', 'NaN',
@@ -150,43 +146,6 @@ def exactly_equal(x, y):
150146

151147
return equal(x, y)
152148

153-
def allclose(x, y, rel_tol=0.25, abs_tol=1, return_indices=False):
154-
"""
155-
Return True all elements of x and y are within tolerance
156-
157-
If return_indices=True, returns (False, (i, j)) when the arrays are not
158-
close, where i and j are the indices into x and y of corresponding
159-
non-close elements.
160-
"""
161-
for i, j in iter_indices(x.shape, y.shape):
162-
i, j = i.raw, j.raw
163-
a = x[i]
164-
b = y[j]
165-
if not (math.isfinite(a) and math.isfinite(b)):
166-
# TODO: If a and b are both infinite, require the same type of infinity
167-
continue
168-
close = math.isclose(a, b, rel_tol=rel_tol, abs_tol=abs_tol)
169-
if not close:
170-
if return_indices:
171-
return (False, (i, j))
172-
return False
173-
return True
174-
175-
def assert_allclose(x, y, rel_tol=1, abs_tol=0.):
176-
"""
177-
Test that x and y are approximately equal to each other.
178-
179-
Also asserts that x and y have the same shape and dtype.
180-
"""
181-
assert x.shape == y.shape, f"The input arrays do not have the same shapes ({x.shape} != {y.shape})"
182-
183-
assert x.dtype == y.dtype, f"The input arrays do not have the same dtype ({x.dtype} != {y.dtype})"
184-
185-
c = allclose(x, y, rel_tol=rel_tol, abs_tol=abs_tol, return_indices=True)
186-
if c is not True:
187-
_, (i, j) = c
188-
raise AssertionError(f"The input arrays are not close with {rel_tol = } and {abs_tol = } at indices {i = } and {j = }")
189-
190149
def notequal(x, y):
191150
"""
192151
Same as not_equal(x, y) except it gives False when both values are nan.

0 commit comments

Comments
 (0)