Skip to content

Commit af98016

Browse files
committed
Update remaining tests in core scope
1 parent 3bf5a76 commit af98016

File tree

11 files changed

+3004
-1
lines changed

11 files changed

+3004
-1
lines changed

dpnp/tests/third_party/cupy/core_tests/test_ndarray.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ class UserNdarray(cupy.ndarray):
138138
)
139139
)
140140
class TestNdarrayInitStrides(unittest.TestCase):
141+
141142
# Check the strides given shape, itemsize and order.
143+
142144
@testing.numpy_cupy_equal()
143145
def test_strides(self, xp):
144146
arr = xp.ndarray(self.shape, dtype=self.dtype, order=self.order)
@@ -149,6 +151,7 @@ def test_strides(self, xp):
149151

150152

151153
class TestNdarrayInitRaise(unittest.TestCase):
154+
152155
def test_unsupported_type(self):
153156
arr = numpy.ndarray((2, 3), dtype=object)
154157
with pytest.raises(TypeError):
@@ -177,6 +180,7 @@ def test_excessive_ndim(self):
177180
)
178181
@pytest.mark.skip("deepcopy() is not supported")
179182
class TestNdarrayDeepCopy(unittest.TestCase):
183+
180184
def _check_deepcopy(self, arr, arr2):
181185
assert arr.data is not arr2.data
182186
assert arr.shape == arr2.shape
@@ -218,6 +222,7 @@ def test_deepcopy_multi_device(self):
218222

219223

220224
class TestNdarrayCopy:
225+
221226
@testing.multi_gpu(2)
222227
@testing.for_orders("CFA")
223228
def test_copy_multi_device_non_contiguous(self, order):
@@ -265,6 +270,7 @@ def test_copy_multi_device_with_stream(self):
265270

266271

267272
class TestNdarrayShape(unittest.TestCase):
273+
268274
@testing.numpy_cupy_array_equal()
269275
def test_shape_set(self, xp):
270276
arr = xp.ndarray((2, 3))
@@ -298,6 +304,7 @@ def test_shape_need_copy(self):
298304

299305
@pytest.mark.skip("CUDA interface is not supported")
300306
class TestNdarrayCudaInterface(unittest.TestCase):
307+
301308
def test_cuda_array_interface(self):
302309
arr = cupy.zeros(shape=(2, 3), dtype=cupy.float64)
303310
iface = arr.__cuda_array_interface__
@@ -428,6 +435,7 @@ def test_cuda_array_interface_stream(self):
428435

429436
@pytest.mark.skip("CUDA interface is not supported")
430437
class TestNdarrayCudaInterfaceNoneCUDA(unittest.TestCase):
438+
431439
def setUp(self):
432440
self.arr = cupy.zeros(shape=(2, 3), dtype=cupy.float64)
433441

@@ -449,6 +457,7 @@ def test_cuda_array_interface_getattr(self):
449457
)
450458
)
451459
class TestNdarrayTake(unittest.TestCase):
460+
452461
shape = (3, 4, 5)
453462

454463
@testing.for_all_dtypes()
@@ -472,6 +481,7 @@ def test_take(self, xp, dtype):
472481
)
473482
)
474483
class TestNdarrayTakeWithInt(unittest.TestCase):
484+
475485
shape = (3, 4, 5)
476486

477487
@testing.for_all_dtypes()
@@ -490,6 +500,7 @@ def test_take(self, xp, dtype):
490500
)
491501
)
492502
class TestNdarrayTakeWithIntWithOutParam(unittest.TestCase):
503+
493504
shape = (3, 4, 5)
494505

495506
@testing.for_all_dtypes()
@@ -512,6 +523,7 @@ def test_take(self, xp, dtype):
512523
)
513524
)
514525
class TestScalaNdarrayTakeWithIntWithOutParam(unittest.TestCase):
526+
515527
shape = ()
516528

517529
@testing.for_all_dtypes()
@@ -530,6 +542,7 @@ def test_take(self, xp, dtype):
530542
{"shape": (), "indices": (0,), "axis": 2},
531543
)
532544
class TestNdarrayTakeErrorAxisOverRun(unittest.TestCase):
545+
533546
def test_axis_overrun1(self):
534547
for xp in (numpy, cupy):
535548
a = testing.shaped_arange(self.shape, xp)
@@ -547,6 +560,7 @@ def test_axis_overrun2(self):
547560
{"shape": (), "indices": (), "out_shape": (1,)},
548561
)
549562
class TestNdarrayTakeErrorShapeMismatch(unittest.TestCase):
563+
550564
def test_shape_mismatch(self):
551565
for xp in (numpy, cupy):
552566
a = testing.shaped_arange(self.shape, xp)
@@ -561,6 +575,7 @@ def test_shape_mismatch(self):
561575
{"shape": (), "indices": (), "out_shape": ()},
562576
)
563577
class TestNdarrayTakeErrorTypeMismatch(unittest.TestCase):
578+
564579
def test_output_type_mismatch(self):
565580
for xp in (numpy, cupy):
566581
a = testing.shaped_arange(self.shape, xp, numpy.int32)
@@ -576,6 +591,7 @@ def test_output_type_mismatch(self):
576591
{"shape": (3, 0), "indices": (2,), "axis": 0},
577592
)
578593
class TestZeroSizedNdarrayTake(unittest.TestCase):
594+
579595
@testing.numpy_cupy_array_equal()
580596
def test_output_type_mismatch(self, xp):
581597
a = testing.shaped_arange(self.shape, xp, numpy.int32)
@@ -588,6 +604,7 @@ def test_output_type_mismatch(self, xp):
588604
{"shape": (0,), "indices": (1, 1)},
589605
)
590606
class TestZeroSizedNdarrayTakeIndexError(unittest.TestCase):
607+
591608
def test_output_type_mismatch(self):
592609
for xp in (numpy, cupy):
593610
a = testing.shaped_arange(self.shape, xp, numpy.int32)
@@ -597,6 +614,7 @@ def test_output_type_mismatch(self):
597614

598615

599616
class TestSize(unittest.TestCase):
617+
600618
@testing.numpy_cupy_equal()
601619
def test_size_without_axis(self, xp):
602620
x = testing.shaped_arange((3, 4, 5), xp, numpy.int32)
@@ -638,6 +656,7 @@ def test_size_zero_dim_array_with_axis(self):
638656

639657
@pytest.mark.skip("python interface is not supported")
640658
class TestPythonInterface(unittest.TestCase):
659+
641660
@testing.for_all_dtypes()
642661
@testing.numpy_cupy_equal()
643662
def test_bytes_tobytes(self, xp, dtype):
@@ -674,13 +693,15 @@ def test_format(self, xp):
674693

675694
@pytest.mark.skip("implicit conversation to numpy does not raise an exception")
676695
class TestNdarrayImplicitConversion(unittest.TestCase):
696+
677697
def test_array(self):
678698
a = testing.shaped_arange((3, 4, 5), cupy, numpy.int64)
679699
with pytest.raises(TypeError):
680700
numpy.asarray(a)
681701

682702

683703
class C(cupy.ndarray):
704+
684705
def __new__(cls, *args, info=None, **kwargs):
685706
obj = super().__new__(cls, *args, **kwargs)
686707
obj.info = info
@@ -694,6 +715,7 @@ def __array_finalize__(self, obj):
694715

695716
@pytest.mark.skip("SAT-7168: explicit constructor call is not supported")
696717
class TestNdarraySubclass:
718+
697719
def test_explicit_constructor_call(self):
698720
a = C([0, 1, 2, 3], info="information")
699721
assert type(a) is C

dpnp/tests/third_party/cupy/core_tests/test_ndarray_complex_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_conjugate_pass(self, xp, dtype):
4242
class TestAngle(unittest.TestCase):
4343

4444
@testing.for_all_dtypes()
45-
@testing.numpy_cupy_array_almost_equal()
45+
@testing.numpy_cupy_array_almost_equal(type_check=has_support_aspect64())
4646
def test_angle(self, xp, dtype):
4747
x = testing.shaped_arange((2, 3), xp, dtype)
4848
return xp.angle(x)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import unittest
2+
3+
import pytest
4+
5+
# from cupy import _core
6+
7+
pytest.skip("owndata attribute is not supported", allow_module_level=True)
8+
9+
10+
class TestArrayOwndata(unittest.TestCase):
11+
12+
def setUp(self):
13+
self.a = _core.ndarray(())
14+
15+
def test_original_array(self):
16+
assert self.a.flags.owndata is True
17+
18+
def test_view_array(self):
19+
v = self.a.view()
20+
assert v.flags.owndata is False
21+
22+
def test_reshaped_array(self):
23+
r = self.a.reshape(())
24+
assert r.flags.owndata is False

0 commit comments

Comments
 (0)