From 40fae53b150255da4bb8939310c98610e90d2f34 Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Sun, 1 Dec 2024 15:25:01 +0200 Subject: [PATCH] limit the range in symmetric_matrices otherwise, using assume(...) triggers a HealthCheck warning that the strategy filters too much --- array_api_tests/hypothesis_helpers.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/array_api_tests/hypothesis_helpers.py b/array_api_tests/hypothesis_helpers.py index 3d5a17f7..6b6c7e3e 100644 --- a/array_api_tests/hypothesis_helpers.py +++ b/array_api_tests/hypothesis_helpers.py @@ -370,17 +370,23 @@ def mutually_broadcastable_shapes( # TODO: Add support for complex Hermitian matrices @composite def symmetric_matrices(draw, dtypes=real_floating_dtypes, finite=True, bound=10.): + # for now, only generate elements from (1, bound); TODO: restore + # generating from (-bound, -1/bound).or.(1/bound, bound) + # Note that using `assume` triggers a HealthCheck for filtering too much. shape = draw(square_matrix_shapes) dtype = draw(dtypes) if not isinstance(finite, bool): finite = draw(finite) - elements = {'allow_nan': False, 'allow_infinity': False} if finite else None + if finite: + elements = {'allow_nan': False, 'allow_infinity': False, + 'min_value': 1, 'max_value': bound} + else: + elements = None a = draw(arrays(dtype=dtype, shape=shape, elements=elements)) at = ah._matrix_transpose(a) H = (a + at)*0.5 if finite: assume(not xp.any(xp.isinf(H))) - assume(xp.all((H == 0.) | ((1/bound <= xp.abs(H)) & (xp.abs(H) <= bound)))) return H @composite