Skip to content

Commit e901687

Browse files
committed
Remove all references to FILTER_UNDEFINED_DTYPES
Never used and inconsistent checking across the test suite
1 parent 7c89cf1 commit e901687

File tree

3 files changed

+14
-26
lines changed

3 files changed

+14
-26
lines changed

array_api_tests/hypothesis_helpers.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@
2222
from .pytest_helpers import nargs
2323
from .typing import Array, DataType, Shape
2424

25-
# Set this to True to not fail tests just because a dtype isn't implemented.
26-
# If no compatible dtype is implemented for a given test, the test will fail
27-
# with a hypothesis health check error. Note that this functionality will not
28-
# work for floating point dtypes as those are assumed to be defined in other
29-
# places in the tests.
30-
FILTER_UNDEFINED_DTYPES = True
31-
# TODO: currently we assume this to be true - we probably can remove this completely
32-
assert FILTER_UNDEFINED_DTYPES
33-
3425
integer_dtypes = xps.integer_dtypes() | xps.unsigned_integer_dtypes()
3526
floating_dtypes = xps.floating_dtypes()
3627
numeric_dtypes = xps.numeric_dtypes()
@@ -62,21 +53,19 @@ def _dtypes_sorter(dtype_pair: Tuple[DataType, DataType]):
6253
return key
6354

6455
_promotable_dtypes = list(dh.promotion_table.keys())
65-
if FILTER_UNDEFINED_DTYPES:
66-
_promotable_dtypes = [
67-
(d1, d2) for d1, d2 in _promotable_dtypes
68-
if not isinstance(d1, _UndefinedStub) or not isinstance(d2, _UndefinedStub)
69-
]
56+
_promotable_dtypes = [
57+
(d1, d2) for d1, d2 in _promotable_dtypes
58+
if not isinstance(d1, _UndefinedStub) or not isinstance(d2, _UndefinedStub)
59+
]
7060
promotable_dtypes: List[Tuple[DataType, DataType]] = sorted(_promotable_dtypes, key=_dtypes_sorter)
7161

7262
def mutually_promotable_dtypes(
7363
max_size: Optional[int] = 2,
7464
*,
7565
dtypes: Sequence[DataType] = dh.all_dtypes,
7666
) -> SearchStrategy[Tuple[DataType, ...]]:
77-
if FILTER_UNDEFINED_DTYPES:
78-
dtypes = [d for d in dtypes if not isinstance(d, _UndefinedStub)]
79-
assert len(dtypes) > 0, "all dtypes undefined" # sanity check
67+
dtypes = [d for d in dtypes if not isinstance(d, _UndefinedStub)]
68+
assert len(dtypes) > 0, "all dtypes undefined" # sanity check
8069
if max_size == 2:
8170
return sampled_from(
8271
[(i, j) for i, j in promotable_dtypes if i in dtypes and j in dtypes]
@@ -424,9 +413,8 @@ def two_mutual_arrays(
424413
) -> Tuple[SearchStrategy[Array], SearchStrategy[Array]]:
425414
if not isinstance(dtypes, Sequence):
426415
raise TypeError(f"{dtypes=} not a sequence")
427-
if FILTER_UNDEFINED_DTYPES:
428-
dtypes = [d for d in dtypes if not isinstance(d, _UndefinedStub)]
429-
assert len(dtypes) > 0 # sanity check
416+
dtypes = [d for d in dtypes if not isinstance(d, _UndefinedStub)]
417+
assert len(dtypes) > 0 # sanity check
430418
mutual_dtypes = shared(mutually_promotable_dtypes(dtypes=dtypes))
431419
mutual_shapes = shared(two_shapes)
432420
arrays1 = xps.arrays(

array_api_tests/test_operators_and_elementwise_functions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,8 @@ def make_unary_params(
468468
*,
469469
min_version: str = "2021.12",
470470
) -> List[Param[UnaryParamContext]]:
471-
if hh.FILTER_UNDEFINED_DTYPES:
472-
dtypes = [d for d in dtypes if not isinstance(d, xp._UndefinedStub)]
471+
dtypes = [d for d in dtypes if not isinstance(d, xp._UndefinedStub)]
472+
assert len(dtypes) > 0 # sanity check
473473
if api_version < "2022.12":
474474
dtypes = [d for d in dtypes if d not in dh.complex_dtypes]
475475
dtypes_strat = st.sampled_from(dtypes)
@@ -523,8 +523,8 @@ def __repr__(self):
523523
def make_binary_params(
524524
elwise_func_name: str, dtypes: Sequence[DataType]
525525
) -> List[Param[BinaryParamContext]]:
526-
if hh.FILTER_UNDEFINED_DTYPES:
527-
dtypes = [d for d in dtypes if not isinstance(d, xp._UndefinedStub)]
526+
dtypes = [d for d in dtypes if not isinstance(d, xp._UndefinedStub)]
527+
assert len(dtypes) > 0 # sanity check
528528
shared_oneway_dtypes = st.shared(hh.oneway_promotable_dtypes(dtypes))
529529
left_dtypes = shared_oneway_dtypes.map(lambda D: D.result_dtype)
530530
right_dtypes = shared_oneway_dtypes.map(lambda D: D.input_dtype)

array_api_tests/test_statistical_functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
def kwarg_dtypes(dtype: DataType) -> st.SearchStrategy[Optional[DataType]]:
2222
dtypes = [d2 for d1, d2 in dh.promotion_table if d1 == dtype]
23-
if hh.FILTER_UNDEFINED_DTYPES:
24-
dtypes = [d for d in dtypes if not isinstance(d, _UndefinedStub)]
23+
dtypes = [d for d in dtypes if not isinstance(d, _UndefinedStub)]
24+
assert len(dtypes) > 0 # sanity check
2525
return st.none() | st.sampled_from(dtypes)
2626

2727

0 commit comments

Comments
 (0)