Skip to content

Commit 59a8135

Browse files
committed
ENH: add a result_type test with a mix of arrays and dtypes
1 parent d6397f8 commit 59a8135

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

array_api_tests/hypothesis_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def mutually_promotable_dtypes(
152152
def pair_of_mutually_promotable_dtypes(draw, max_size=2, *, dtypes=dh.all_dtypes):
153153
sample = draw(mutually_promotable_dtypes( max_size, dtypes=dtypes))
154154
permuted = draw(permutations(sample))
155-
return sample, permuted
155+
return sample, tuple(permuted)
156156

157157

158158
class OnewayPromotableDtypes(NamedTuple):

array_api_tests/test_data_type_functions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,11 @@ def test_shuffled(self, pair):
222222
out2 = xp.result_type(*s2)
223223
assert out1 == out2
224224

225+
@given(pair=hh.pair_of_mutually_promotable_dtypes(2), data=st.data())
226+
def test_arrays_and_dtypes(self, pair, data):
227+
s1, s2 = pair
228+
a2 = tuple(xp.empty(1, dtype=dt) for dt in s2)
229+
a_and_dt = data.draw(st.permutations(s1 + a2))
230+
out = xp.result_type(*a_and_dt)
231+
ph.assert_dtype("result_type", in_dtype=s1+s2, out_dtype=out, repr_name="out")
232+

0 commit comments

Comments
 (0)