Skip to content

Commit 9bb8c7a

Browse files
committed
Use assert_allclose() in the linalg tests for float inputs
Fixes data-apis#44. Related to data-apis#117.
1 parent 414b322 commit 9bb8c7a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

array_api_tests/test_linalg.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import itertools
2424

25-
from .array_helpers import assert_exactly_equal, asarray
25+
from .array_helpers import assert_exactly_equal, asarray, assert_allclose
2626
from .hypothesis_helpers import (xps, dtypes, shapes, kwargs, matrix_shapes,
2727
square_matrix_shapes, symmetric_matrices,
2828
positive_definite_matrices, MAX_ARRAY_SIZE,
@@ -44,9 +44,15 @@
4444
# Standin strategy for not yet implemented tests
4545
todo = none()
4646

47+
def assert_equal(x, y):
48+
if x.dtype in dh.float_dtypes:
49+
assert_allclose(x, y)
50+
else:
51+
assert_exactly_equal(x, y)
52+
4753
def _test_stacks(f, *args, res=None, dims=2, true_val=None,
4854
matrix_axes=(-2, -1),
49-
assert_equal=assert_exactly_equal, **kw):
55+
assert_equal=assert_equal, **kw):
5056
"""
5157
Test that f(*args, **kw) maps across stacks of matrices
5258

0 commit comments

Comments
 (0)