Skip to content

Commit 9e45097

Browse files
committed
Add meta tests for the matrices strategies
1 parent 1f88f2d commit 9e45097

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

array_api_tests/hypothesis_helpers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
dtypes = dtypes.filter(lambda x: not isinstance(x, _UndefinedStub))
4949

5050
shared_dtypes = shared(dtypes, key="dtype")
51+
shared_floating_dtypes = shared(floating_dtypes, key="dtype")
5152

5253
# TODO: Importing things from test_type_promotion should be replaced by
5354
# something that won't cause a circular import. Right now we use @st.composite

array_api_tests/meta_tests/test_hypothesis_helpers.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
UNDEFINED_DTYPES = any(isinstance(d, _UndefinedStub) for d in ah.dtype_objects)
1212
pytestmark = [pytest.mark.skipif(UNDEFINED_DTYPES, reason="undefined dtypes")]
1313

14-
1514
@given(hh.mutually_promotable_dtypes([xp.float32, xp.float64]))
1615
def test_mutually_promotable_dtypes(pairs):
1716
assert pairs in (
@@ -70,3 +69,15 @@ def run(kw):
7069
c_results = [kw for kw in results if "c" in kw]
7170
assert len(c_results) > 0
7271
assert all(isinstance(kw["c"], str) for kw in c_results)
72+
73+
@given(hh.symmetric_matrices(hh.shared_floating_dtypes), hh.shared_floating_dtypes)
74+
def test_symmetric_matrices(m, dtype):
75+
assert m.dtype == dtype
76+
# TODO: This part of this test should be part of the .mT test
77+
ah.assert_exactly_equal(m, m.mT)
78+
79+
80+
@given(hh.positive_definite_matrices(hh.shared_floating_dtypes), hh.shared_floating_dtypes)
81+
def test_positive_definite_matrices(m, dtype):
82+
assert m.dtype == dtype
83+
# TODO: Test that it actually is positive definite

0 commit comments

Comments
 (0)