Skip to content

Commit b2e3634

Browse files
committed
Add helper test function get_array
1 parent 6318af3 commit b2e3634

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

dpnp/tests/helper.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,20 @@ def get_all_dtypes(
161161
return dtypes
162162

163163

164+
def get_array(xp, a):
165+
"""
166+
Cast input array `a` to a type supported by `xp` initerface.
167+
168+
Implicit conversion of either DPNP or DPCTL array to a NumPy array is not
169+
allowed. Input array has to be explicitly casted with `asnumpy` function.
170+
171+
"""
172+
173+
if xp is numpy and dpnp.is_supported_array_type(a):
174+
return dpnp.asnumpy(a)
175+
return a
176+
177+
164178
def generate_random_numpy_array(
165179
shape,
166180
dtype=None,

0 commit comments

Comments
 (0)