Skip to content

Commit 7a04d35

Browse files
author
Vahid Tavanashad
committed
address comments
1 parent 183462f commit 7a04d35

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

dpnp/dpnp_iface_arraycreation.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,11 @@ def array(
377377
>>> x
378378
array([1, 2, 3])
379379
380+
Upcasting:
381+
382+
>>> np.array([1, 2, 3.0])
383+
array([ 1., 2., 3.])
384+
380385
More than one dimension:
381386
382387
>>> x2 = np.array([[1, 2], [3, 4]])
@@ -386,6 +391,16 @@ def array(
386391
array([[1, 2],
387392
[3, 4]])
388393
394+
Minimum dimensions 2:
395+
396+
>>> np.array([1, 2, 3], ndmin=2)
397+
array([[1, 2, 3]])
398+
399+
Type provided:
400+
401+
>>> np.array([1, 2, 3], dtype=complex)
402+
array([ 1.+0.j, 2.+0.j, 3.+0.j])
403+
389404
Creating an array on a different device or with a specified usm_type
390405
391406
>>> x = np.array([1, 2, 3]) # default case

tests/third_party/cupy/creation_tests/test_from_data.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -514,14 +514,14 @@ def test_copy(self, xp, dtype, order):
514514
a[1] = 1
515515
return b
516516

517-
@pytest.mark.skip("`device` argument isn't supported")
518517
@testing.for_CF_orders()
519518
@testing.for_all_dtypes()
520519
def test_copy_multigpu(self, dtype, order):
521-
with cuda.Device(0):
522-
src = cupy.random.uniform(-1, 1, (2, 3)).astype(dtype)
523-
with cuda.Device(1):
524-
dst = cupy.copy(src, order)
520+
q1 = dpctl.SyclQueue()
521+
q2 = dpctl.SyclQueue()
522+
523+
src = cupy.random.uniform(-1, 1, (2, 3), device=q1).astype(dtype)
524+
dst = cupy.copy(src, order, device=q2)
525525
testing.assert_allclose(src, dst, rtol=0, atol=0)
526526

527527
@testing.for_CF_orders()
@@ -804,10 +804,13 @@ def test_cupy_array(self, dtype):
804804
assert a.shape == shape
805805

806806

807-
# TODO: ndmin=3 is removed since it needs ndarray.base
808807
@testing.parameterize(
809808
*testing.product(
810-
{"ndmin": [0, 1, 2], "copy": [True, False, None], "xp": [numpy, cupy]}
809+
{
810+
"ndmin": [0, 1, 2, 3],
811+
"copy": [True, False, None],
812+
"xp": [numpy, cupy],
813+
}
811814
)
812815
)
813816
class TestArrayCopy(unittest.TestCase):
@@ -823,8 +826,8 @@ def test_cupy_array(self, dtype):
823826
# TODO(Kenta Oono): Better determination of copy.
824827
is_copied = not (
825828
(actual is a)
826-
# or (actual.base is a)
827-
# or (actual.base is a.base and a.base is not None)
829+
or (self.xp is cupy)
830+
and (a.get_array()._pointer == actual.get_array()._pointer)
828831
)
829832
assert should_copy == is_copied
830833

0 commit comments

Comments
 (0)