Skip to content

Commit af389a8

Browse files
committed
ENH: add a result_type test with a mix of arrays and dtypes
1 parent 0ecc4f0 commit af389a8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

array_api_tests/hypothesis_helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def mutually_promotable_dtypes(
156156
def pair_of_mutually_promotable_dtypes(draw, max_size=2, *, dtypes=dh.all_dtypes):
157157
sample = draw(mutually_promotable_dtypes( max_size, dtypes=dtypes))
158158
permuted = draw(permutations(sample))
159-
return sample, permuted
159+
return sample, tuple(permuted)
160160

161161

162162
class OnewayPromotableDtypes(NamedTuple):

array_api_tests/test_data_type_functions.py

+8
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)