Skip to content

Commit

Permalink
Use assert_allclose() in the linalg tests for float inputs
Browse files Browse the repository at this point in the history
Fixes data-apis#44.
Related to data-apis#117.
  • Loading branch information
asmeurer committed Apr 25, 2022
1 parent 414b322 commit 9bb8c7a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions array_api_tests/test_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import itertools

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

def assert_equal(x, y):
if x.dtype in dh.float_dtypes:
assert_allclose(x, y)
else:
assert_exactly_equal(x, y)

def _test_stacks(f, *args, res=None, dims=2, true_val=None,
matrix_axes=(-2, -1),
assert_equal=assert_exactly_equal, **kw):
assert_equal=assert_equal, **kw):
"""
Test that f(*args, **kw) maps across stacks of matrices
Expand Down

0 comments on commit 9bb8c7a

Please sign in to comment.