Skip to content

Commit e44051d

Browse files
committed
Defined shared_optional_promotable_dtype
1 parent 68d7560 commit e44051d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

array_api_tests/hypothesis_helpers.py

+6
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,9 @@ def multiaxis_indices(draw, shapes):
243243
extra = draw(lists(one_of(integer_indices(sizes), slices(sizes)), min_size=0, max_size=3))
244244
res += extra
245245
return tuple(res)
246+
247+
248+
shared_optional_promotable_dtypes = one_of(
249+
none(),
250+
promotable_dtypes(shared_dtypes),
251+
)

array_api_tests/test_creation_functions.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
assert_exactly_equal, isintegral, is_float_dtype)
66
from .hypothesis_helpers import (numeric_dtypes, dtypes, MAX_ARRAY_SIZE, promotable_dtypes,
77
shapes, sizes, sqrt_sizes, shared_dtypes,
8-
scalars, xps)
8+
scalars, xps, shared_optional_promotable_dtypes)
99

1010
from hypothesis import assume, given
1111
from hypothesis.strategies import integers, floats, one_of, none, booleans, just
1212

13+
14+
1315
int_range = integers(-MAX_ARRAY_SIZE, MAX_ARRAY_SIZE)
1416
float_range = floats(-MAX_ARRAY_SIZE, MAX_ARRAY_SIZE,
1517
allow_nan=False)
@@ -84,7 +86,7 @@ def test_empty(shape, dtype):
8486
dtype=shared_dtypes,
8587
shape=shapes,
8688
),
87-
dtype=one_of(none(), promotable_dtypes(shared_dtypes)),
89+
dtype=shared_optional_promotable_dtypes,
8890
)
8991
def test_empty_like(a, dtype):
9092
kwargs = {} if dtype is None else {'dtype': dtype}
@@ -156,7 +158,7 @@ def test_full(shape, fill_value, dtype):
156158
shape=shapes,
157159
),
158160
fill_value=promotable_dtypes(shared_dtypes).flatmap(xps.from_dtype),
159-
dtype=one_of(none(), promotable_dtypes(shared_dtypes)),
161+
dtype=shared_optional_promotable_dtypes,
160162
)
161163
def test_full_like(a, fill_value, dtype):
162164
kwargs = {} if dtype is None else {'dtype': dtype}
@@ -247,7 +249,7 @@ def test_ones(shape, dtype):
247249
dtype=shared_dtypes,
248250
shape=shapes,
249251
),
250-
dtype=one_of(none(), promotable_dtypes(shared_dtypes)),
252+
dtype=shared_optional_promotable_dtypes,
251253
)
252254
def test_ones_like(a, dtype):
253255
kwargs = {} if dtype is None else {'dtype': dtype}
@@ -298,7 +300,7 @@ def test_zeros(shape, dtype):
298300
dtype=shared_dtypes,
299301
shape=shapes,
300302
),
301-
dtype=one_of(none(), promotable_dtypes(shared_dtypes)),
303+
dtype=shared_optional_promotable_dtypes,
302304
)
303305
def test_zeros_like(a, dtype):
304306
kwargs = {} if dtype is None else {'dtype': dtype}

0 commit comments

Comments
 (0)