Skip to content

Commit 306aa74

Browse files
authored
Align default order value with numpy in asarray-like functions (#1526)
* Aligned default order value with numpy * Added test for exceptions use case * Muted missing not working tests & python 3.10
1 parent e3fd477 commit 306aa74

10 files changed

+652
-398
lines changed

dpnp/dpnp_container.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def arange(
8686
def asarray(
8787
x1,
8888
dtype=None,
89-
copy=False,
90-
order="C",
89+
copy=None,
90+
order=None,
9191
device=None,
9292
usm_type=None,
9393
sycl_queue=None,
@@ -96,7 +96,7 @@ def asarray(
9696
dpu.validate_usm_type(usm_type, allow_none=True)
9797

9898
if order is None:
99-
order = "C"
99+
order = "K"
100100

101101
"""Converts incoming 'x1' object to 'dpnp_array'."""
102102
if isinstance(x1, (list, tuple, range)):
@@ -127,6 +127,11 @@ def asarray(
127127
usm_type=usm_type,
128128
sycl_queue=sycl_queue_normalized,
129129
)
130+
131+
# return x1 if dpctl returns a zero copy of x1_obj
132+
if array_obj is x1_obj:
133+
return x1
134+
130135
return dpnp_array(array_obj.shape, buffer=array_obj, order=order)
131136

132137

dpnp/dpnp_iface.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def get_dpnp_descriptor(
310310

311311
if ext_obj.strides != shape_offsets or ext_obj_offset != 0:
312312
orig_desc = dpnp_descriptor(ext_obj)
313-
ext_obj = array(ext_obj)
313+
ext_obj = array(ext_obj, order="C")
314314

315315
# while dpnp functions are based on DPNP_QUEUE
316316
# we need to create a copy on device associated with DPNP_QUEUE

0 commit comments

Comments
 (0)