From a484267251184d6bb8177da1ff77c68ecfc8d409 Mon Sep 17 00:00:00 2001 From: Natalia Polina Date: Tue, 10 Oct 2023 18:12:12 -0500 Subject: [PATCH 1/3] Updated atleast_2d and atleast_3d functions. --- dpnp/dpnp_algo/dpnp_algo_manipulation.pxi | 56 ------- dpnp/dpnp_iface_manipulation.py | 141 +++++++++++------- tests/test_arraymanipulation.py | 71 +++++++++ .../cupy/manipulation_tests/test_dims.py | 2 - 4 files changed, 158 insertions(+), 112 deletions(-) diff --git a/dpnp/dpnp_algo/dpnp_algo_manipulation.pxi b/dpnp/dpnp_algo/dpnp_algo_manipulation.pxi index f483b5b05c37..7a517ac261fc 100644 --- a/dpnp/dpnp_algo/dpnp_algo_manipulation.pxi +++ b/dpnp/dpnp_algo/dpnp_algo_manipulation.pxi @@ -36,8 +36,6 @@ and the rest of the library # NO IMPORTs here. All imports must be placed into main "dpnp_algo.pyx" file __all__ += [ - "dpnp_atleast_2d", - "dpnp_atleast_3d", "dpnp_repeat", ] @@ -48,60 +46,6 @@ ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_dpnp_repeat_t)(c_dpctl.DPCTLSyclQueueRe const c_dpctl.DPCTLEventVectorRef) -cpdef utils.dpnp_descriptor dpnp_atleast_2d(utils.dpnp_descriptor arr): - # it looks like it should be dpnp.copy + dpnp.reshape - cdef utils.dpnp_descriptor result - cdef size_t arr_ndim = arr.ndim - cdef long arr_size = arr.size - if arr_ndim == 1: - arr_obj = arr.get_array() - result = utils_py.create_output_descriptor_py((1, arr_size), - arr.dtype, - None, - device=arr_obj.sycl_device, - usm_type=arr_obj.usm_type, - sycl_queue=arr_obj.sycl_queue) - for i in range(arr_size): - result.get_pyobj()[0, i] = arr.get_pyobj()[i] - return result - else: - return arr - - -cpdef utils.dpnp_descriptor dpnp_atleast_3d(utils.dpnp_descriptor arr): - # it looks like it should be dpnp.copy + dpnp.reshape - cdef utils.dpnp_descriptor result - cdef size_t arr_ndim = arr.ndim - cdef shape_type_c arr_shape = arr.shape - cdef long arr_size = arr.size - - arr_obj = arr.get_array() - - if arr_ndim == 1: - result = utils_py.create_output_descriptor_py((1, 1, arr_size), - arr.dtype, - None, - device=arr_obj.sycl_device, - usm_type=arr_obj.usm_type, - sycl_queue=arr_obj.sycl_queue) - for i in range(arr_size): - result.get_pyobj()[0, 0, i] = arr.get_pyobj()[i] - return result - elif arr_ndim == 2: - result = utils_py.create_output_descriptor_py((1, arr_shape[0], arr_shape[1]), - arr.dtype, - None, - device=arr_obj.sycl_device, - usm_type=arr_obj.usm_type, - sycl_queue=arr_obj.sycl_queue) - for i in range(arr_shape[0]): - for j in range(arr_shape[1]): - result.get_pyobj()[0, i, j] = arr.get_pyobj()[i, j] - return result - else: - return arr - - cpdef utils.dpnp_descriptor dpnp_repeat(utils.dpnp_descriptor array1, repeats, axes=None): cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(array1.dtype) diff --git a/dpnp/dpnp_iface_manipulation.py b/dpnp/dpnp_iface_manipulation.py index a9de67e965b5..355590972844 100644 --- a/dpnp/dpnp_iface_manipulation.py +++ b/dpnp/dpnp_iface_manipulation.py @@ -183,36 +183,52 @@ def atleast_2d(*arys): For full documentation refer to :obj:`numpy.atleast_2d`. - Limitations - ----------- - Input arrays is supported as :obj:`dpnp.ndarray`. - """ + Parameters + ---------- + arys : {dpnp_array, usm_ndarray} + One or more array-like sequences. Non-array inputs are converted + to arrays. Arrays that already have two or more dimensions are + preserved. + + Returns + ------- + out : dpnp.ndarray + An array, or list of arrays, each with ``a.ndim >= 2``. + Copies are avoided where possible, and views with two or more + dimensions are returned. + + See Also + -------- + atleast_1d, atleast_3d + + Examples + -------- + >>> import dpnp as np + >>> np.atleast_2d(3.0) + array([[3.]]) + + >>> x = np.arange(3.0) + >>> np.atleast_2d(x) + array([[0., 1., 2.]]) + + >>> np.atleast_2d(1, [1, 2], [[1, 2]]) + [array([[1]]), array([[1, 2]]), array([[1, 2]])] - all_is_array = True - arys_desc = [] + """ + res = [] for ary in arys: - if not dpnp.isscalar(ary): - ary_desc = dpnp.get_dpnp_descriptor( - ary, copy_when_nondefault_queue=False - ) - if ary_desc: - arys_desc.append(ary_desc) - continue - all_is_array = False - break - - if not use_origin_backend(arys[0]) and all_is_array: - result = [] - for ary_desc in arys_desc: - res = dpnp_atleast_2d(ary_desc).get_pyobj() - result.append(res) - - if len(result) == 1: - return result[0] + ary = dpnp.asanyarray(ary) + if ary.ndim == 0: + result = ary.reshape(1, 1) + elif ary.ndim == 1: + result = ary[dpnp.newaxis, :] else: - return result - - return call_origin(numpy.atleast_2d, *arys) + result = ary + res.append(result) + if len(res) == 1: + return res[0] + else: + return res def atleast_3d(*arys): @@ -221,36 +237,53 @@ def atleast_3d(*arys): For full documentation refer to :obj:`numpy.atleast_3d`. - Limitations - ----------- - Input arrays is supported as :obj:`dpnp.ndarray`. - """ + Parameters + ---------- + arys : {dpnp_array, usm_ndarray} + One or more array-like sequences. Non-array inputs are converted to + arrays. Arrays that already have three or more dimensions are + preserved. + + Returns + ------- + out : dpnp.ndarray + An array, or list of arrays, each with ``a.ndim >= 3``. Copies are + avoided where possible, and views with three or more dimensions are + returned. For example, a 1-D array of shape ``(N,)`` becomes a view + of shape ``(1, N, 1)``, and a 2-D array of shape ``(M, N)`` becomes a + view of shape ``(M, N, 1)``. + + Examples + -------- + >>> import dpnp as np + >>> np.atleast_3d(3.0) + array([[[3.]]]) - all_is_array = True - arys_desc = [] + >>> x = np.arange(3.0) + >>> np.atleast_3d(x).shape + (1, 3, 1) + + >>> x = np.arange(12.0).reshape(4,3) + >>> np.atleast_3d(x).shape + (4, 3, 1) + + """ + res = [] for ary in arys: - if not dpnp.isscalar(ary): - ary_desc = dpnp.get_dpnp_descriptor( - ary, copy_when_nondefault_queue=False - ) - if ary_desc: - arys_desc.append(ary_desc) - continue - all_is_array = False - break - - if not use_origin_backend(arys[0]) and all_is_array: - result = [] - for ary_desc in arys_desc: - res = dpnp_atleast_3d(ary_desc).get_pyobj() - result.append(res) - - if len(result) == 1: - return result[0] + ary = dpnp.asanyarray(ary) + if ary.ndim == 0: + result = ary.reshape(1, 1, 1) + elif ary.ndim == 1: + result = ary[dpnp.newaxis, :, dpnp.newaxis] + elif ary.ndim == 2: + result = ary[:, :, dpnp.newaxis] else: - return result - - return call_origin(numpy.atleast_3d, *arys) + result = ary + res.append(result) + if len(res) == 1: + return res[0] + else: + return res def broadcast_to(array, /, shape, subok=False): diff --git a/tests/test_arraymanipulation.py b/tests/test_arraymanipulation.py index 1c98c487dfc2..ba73bdf3805d 100644 --- a/tests/test_arraymanipulation.py +++ b/tests/test_arraymanipulation.py @@ -725,3 +725,74 @@ def test_results(self): jp = j + 1 if j < 4 else j res = dpnp.rollaxis(dp_a, axis=-ip, start=-jp) exp = numpy.rollaxis(np_a, axis=-ip, start=-jp) + + +class TestAtleast2d: + def test_0D_array(self): + a = dpnp.array(1) + b = dpnp.array(2) + res = [dpnp.atleast_2d(a), dpnp.atleast_2d(b)] + desired = [dpnp.array([[1]]), dpnp.array([[2]])] + assert_array_equal(res, desired) + + def test_1D_array(self): + a = dpnp.array([1, 2]) + b = dpnp.array([2, 3]) + res = [dpnp.atleast_2d(a), dpnp.atleast_2d(b)] + desired = [dpnp.array([[1, 2]]), dpnp.array([[2, 3]])] + assert_array_equal(res, desired) + + def test_2D_array(self): + a = dpnp.array([[1, 2], [1, 2]]) + b = dpnp.array([[2, 3], [2, 3]]) + res = [dpnp.atleast_2d(a), dpnp.atleast_2d(b)] + desired = [a, b] + assert_array_equal(res, desired) + + def test_3D_array(self): + a = dpnp.array([[1, 2], [1, 2]]) + b = dpnp.array([[2, 3], [2, 3]]) + a = dpnp.array([a, a]) + b = dpnp.array([b, b]) + res = [dpnp.atleast_2d(a), dpnp.atleast_2d(b)] + desired = [a, b] + assert_array_equal(res, desired) + + def test_r2array(self): + """Test to make sure equivalent Travis O's r2array function""" + assert dpnp.atleast_2d(3).shape == (1, 1) + assert dpnp.atleast_2d([3j, 1]).shape == (1, 2) + array = dpnp.atleast_2d([[[3, 1], [4, 5]], [[3, 5], [1, 2]]]) + assert array.shape == (2, 2, 2) + + +class TestAtleast3d: + def test_0D_array(self): + a = dpnp.array(1) + b = dpnp.array(2) + res = [dpnp.atleast_3d(a), dpnp.atleast_3d(b)] + desired = [dpnp.array([[[1]]]), dpnp.array([[[2]]])] + assert_array_equal(res, desired) + + def test_1D_array(self): + a = dpnp.array([1, 2]) + b = dpnp.array([2, 3]) + res = [dpnp.atleast_3d(a), dpnp.atleast_3d(b)] + desired = [dpnp.array([[[1], [2]]]), dpnp.array([[[2], [3]]])] + assert_array_equal(res, desired) + + def test_2D_array(self): + a = dpnp.array([[1, 2], [1, 2]]) + b = dpnp.array([[2, 3], [2, 3]]) + res = [dpnp.atleast_3d(a), dpnp.atleast_3d(b)] + desired = [a[:, :, dpnp.newaxis], b[:, :, dpnp.newaxis]] + assert_array_equal(res, desired) + + def test_3D_array(self): + a = dpnp.array([[1, 2], [1, 2]]) + b = dpnp.array([[2, 3], [2, 3]]) + a = dpnp.array([a, a]) + b = dpnp.array([b, b]) + res = [dpnp.atleast_3d(a), dpnp.atleast_3d(b)] + desired = [a, b] + assert_array_equal(res, desired) diff --git a/tests/third_party/cupy/manipulation_tests/test_dims.py b/tests/third_party/cupy/manipulation_tests/test_dims.py index 461c0bb2ec2b..d0e815e3f0a2 100644 --- a/tests/third_party/cupy/manipulation_tests/test_dims.py +++ b/tests/third_party/cupy/manipulation_tests/test_dims.py @@ -27,7 +27,6 @@ def test_atleast_1d2(self, xp): a = testing.shaped_arange((1, 3, 2), xp) return xp.atleast_1d(a) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") @testing.numpy_cupy_array_equal() def test_atleast_2d1(self, xp): return self.check_atleast(xp.atleast_2d, xp) @@ -37,7 +36,6 @@ def test_atleast_2d2(self, xp): a = testing.shaped_arange((1, 3, 2), xp) return xp.atleast_2d(a) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") @testing.numpy_cupy_array_equal() def test_atleast_3d1(self, xp): return self.check_atleast(xp.atleast_3d, xp) From 20551de2c3c3aa0c92d44458d12ca55d8c53ae68 Mon Sep 17 00:00:00 2001 From: Natalia Polina Date: Wed, 11 Oct 2023 17:33:43 -0500 Subject: [PATCH 2/3] Removed ability to work with scalars from functions dpnp.atleast_1d, dpnp.atleast_2d, dpnp.atleast_3d --- dpnp/dpnp_iface_manipulation.py | 85 ++++++++++++++++++++------------- tests/skipped_tests.tbl | 5 ++ tests/skipped_tests_gpu.tbl | 4 ++ tests/test_arraymanipulation.py | 13 ----- 4 files changed, 62 insertions(+), 45 deletions(-) diff --git a/dpnp/dpnp_iface_manipulation.py b/dpnp/dpnp_iface_manipulation.py index 355590972844..c8e71e94a1b8 100644 --- a/dpnp/dpnp_iface_manipulation.py +++ b/dpnp/dpnp_iface_manipulation.py @@ -124,14 +124,11 @@ def atleast_1d(*arys): """ Convert inputs to arrays with at least one dimension. - Scalar inputs are converted to 1-dimensional arrays, whilst - higher-dimensional inputs are preserved. - For full documentation refer to :obj:`numpy.atleast_1d`. Parameters ---------- - arys : {dpnp_array, usm_ndarray} + arys : {dpnp.ndarray, usm_ndarray} One or more input arrays. Returns @@ -142,14 +139,20 @@ def atleast_1d(*arys): See Also -------- - atleast_2d, atleast_3d + :obj:`dpnp.atleast_2d` : View inputs as arrays with at least two dimensions. + :obj:`dpnp.atleast_3d` : View inputs as arrays with at least three dimensions. Examples -------- >>> import dpnp as np - >>> np.atleast_1d(1.0) + >>> x = np.array(1.0) + >>> np.atleast_1d(x) array([1.]) + >>> y = np.array([3, 4]) + >>> np.atleast_1d(x, y) + [array([1.]), array([3, 4])] + >>> x = np.arange(9.0).reshape(3,3) >>> np.atleast_1d(x) array([[0., 1., 2.], @@ -158,18 +161,21 @@ def atleast_1d(*arys): >>> np.atleast_1d(x) is x True - >>> np.atleast_1d(1, [3, 4]) - [array([1]), array([3, 4])] - """ res = [] for ary in arys: - ary = dpnp.asanyarray(ary) + if not dpnp.is_supported_array_type(ary): + raise TypeError( + "All arrays must be any of supported type, " + f"but got {type(ary)}" + ) if ary.ndim == 0: result = ary.reshape(1) else: result = ary + if isinstance(result, dpt.usm_ndarray): + result = dpnp_array._create_from_usm_ndarray(result) res.append(result) if len(res) == 1: return res[0] @@ -185,10 +191,9 @@ def atleast_2d(*arys): Parameters ---------- - arys : {dpnp_array, usm_ndarray} - One or more array-like sequences. Non-array inputs are converted - to arrays. Arrays that already have two or more dimensions are - preserved. + arys : {dpnp.ndarray, usm_ndarray} + One or more array-like sequences. Arrays that already have two or more + dimensions are preserved. Returns ------- @@ -199,31 +204,37 @@ def atleast_2d(*arys): See Also -------- - atleast_1d, atleast_3d + :obj:`dpnp.atleast_1d` : Convert inputs to arrays with at least one dimension. + :obj:`dpnp.atleast_3d` : View inputs as arrays with at least three dimensions. Examples -------- >>> import dpnp as np - >>> np.atleast_2d(3.0) + >>> x = np.array(3.0) + >>> np.atleast_2d(x) array([[3.]]) >>> x = np.arange(3.0) >>> np.atleast_2d(x) array([[0., 1., 2.]]) - >>> np.atleast_2d(1, [1, 2], [[1, 2]]) - [array([[1]]), array([[1, 2]]), array([[1, 2]])] - """ + res = [] for ary in arys: - ary = dpnp.asanyarray(ary) + if not dpnp.is_supported_array_type(ary): + raise TypeError( + "All arrays must be any of supported type, " + f"but got {type(ary)}" + ) if ary.ndim == 0: result = ary.reshape(1, 1) elif ary.ndim == 1: result = ary[dpnp.newaxis, :] else: result = ary + if isinstance(result, dpt.usm_ndarray): + result = dpnp_array._create_from_usm_ndarray(result) res.append(result) if len(res) == 1: return res[0] @@ -231,7 +242,7 @@ def atleast_2d(*arys): return res -def atleast_3d(*arys): +def atleast_3d(*arys, device=None, usm_type=None, sycl_queue=None): """ View inputs as arrays with at least three dimensions. @@ -239,38 +250,46 @@ def atleast_3d(*arys): Parameters ---------- - arys : {dpnp_array, usm_ndarray} - One or more array-like sequences. Non-array inputs are converted to - arrays. Arrays that already have three or more dimensions are - preserved. + arys : {dpnp.ndarray, usm_ndarray} + One or more array-like sequences. Arrays that already have three or more + dimensions are preserved. Returns ------- out : dpnp.ndarray - An array, or list of arrays, each with ``a.ndim >= 3``. Copies are + An array, or list of arrays, each with ``a.ndim >= 3``. Copies are avoided where possible, and views with three or more dimensions are - returned. For example, a 1-D array of shape ``(N,)`` becomes a view - of shape ``(1, N, 1)``, and a 2-D array of shape ``(M, N)`` becomes a - view of shape ``(M, N, 1)``. + returned. + + See Also + -------- + :obj:`dpnp.atleast_1d` : Convert inputs to arrays with at least one dimension. + :obj:`dpnp.atleast_2d` : View inputs as arrays with at least three dimensions. Examples -------- >>> import dpnp as np - >>> np.atleast_3d(3.0) + >>> x = np.array(3.0) + >>> np.atleast_3d(x) array([[[3.]]]) >>> x = np.arange(3.0) >>> np.atleast_3d(x).shape (1, 3, 1) - >>> x = np.arange(12.0).reshape(4,3) + >>> x = np.arange(12.0).reshape(4, 3) >>> np.atleast_3d(x).shape (4, 3, 1) """ + res = [] for ary in arys: - ary = dpnp.asanyarray(ary) + if not dpnp.is_supported_array_type(ary): + raise TypeError( + "All arrays must be any of supported type, " + f"but got {type(ary)}" + ) if ary.ndim == 0: result = ary.reshape(1, 1, 1) elif ary.ndim == 1: @@ -279,6 +298,8 @@ def atleast_3d(*arys): result = ary[:, :, dpnp.newaxis] else: result = ary + if isinstance(result, dpt.usm_ndarray): + result = dpnp_array._create_from_usm_ndarray(result) res.append(result) if len(res) == 1: return res[0] diff --git a/tests/skipped_tests.tbl b/tests/skipped_tests.tbl index ccf926dc7700..437f38353924 100644 --- a/tests/skipped_tests.tbl +++ b/tests/skipped_tests.tbl @@ -432,6 +432,11 @@ tests/third_party/cupy/logic_tests/test_comparison.py::TestArrayEqual::test_arra tests/third_party/cupy/logic_tests/test_comparison.py::TestArrayEqual::test_array_equal_diff_length tests/third_party/cupy/logic_tests/test_comparison.py::TestArrayEqual::test_array_equal_is_equal tests/third_party/cupy/logic_tests/test_comparison.py::TestArrayEqual::test_array_equal_not_equal + +tests/third_party/cupy/manipulation_tests/test_dims.py::TestDims::test_atleast_1d1 +tests/third_party/cupy/manipulation_tests/test_dims.py::TestDims::test_atleast_2d1 +tests/third_party/cupy/manipulation_tests/test_dims.py::TestDims::test_atleast_3d1 + tests/third_party/cupy/manipulation_tests/test_dims.py::TestBroadcast_param_0_{shapes=[(), ()]}::test_broadcast tests/third_party/cupy/manipulation_tests/test_dims.py::TestBroadcast_param_0_{shapes=[(), ()]}::test_broadcast_arrays tests/third_party/cupy/manipulation_tests/test_dims.py::TestBroadcast_param_10_{shapes=[(0, 1, 1, 0, 3), (5, 2, 0, 1, 0, 0, 3), (2, 1, 0, 0, 0, 3)]}::test_broadcast diff --git a/tests/skipped_tests_gpu.tbl b/tests/skipped_tests_gpu.tbl index e36491861a48..6bc6289d87db 100644 --- a/tests/skipped_tests_gpu.tbl +++ b/tests/skipped_tests_gpu.tbl @@ -572,6 +572,10 @@ tests/third_party/cupy/logic_tests/test_comparison.py::TestArrayEqual::test_arra tests/third_party/cupy/logic_tests/test_comparison.py::TestArrayEqual::test_array_equal_is_equal tests/third_party/cupy/logic_tests/test_comparison.py::TestArrayEqual::test_array_equal_not_equal +tests/third_party/cupy/manipulation_tests/test_dims.py::TestDims::test_atleast_1d1 +tests/third_party/cupy/manipulation_tests/test_dims.py::TestDims::test_atleast_2d1 +tests/third_party/cupy/manipulation_tests/test_dims.py::TestDims::test_atleast_3d1 + tests/third_party/cupy/manipulation_tests/test_dims.py::TestBroadcast_param_0_{shapes=[(), ()]}::test_broadcast tests/third_party/cupy/manipulation_tests/test_dims.py::TestBroadcast_param_0_{shapes=[(), ()]}::test_broadcast_arrays tests/third_party/cupy/manipulation_tests/test_dims.py::TestBroadcast_param_10_{shapes=[(0, 1, 1, 0, 3), (5, 2, 0, 1, 0, 0, 3), (2, 1, 0, 0, 0, 3)]}::test_broadcast diff --git a/tests/test_arraymanipulation.py b/tests/test_arraymanipulation.py index ba73bdf3805d..efbb930661e2 100644 --- a/tests/test_arraymanipulation.py +++ b/tests/test_arraymanipulation.py @@ -655,12 +655,6 @@ def test_3D_array(self): desired = [a, b] assert_array_equal(res, desired) - def test_r1array(self): - assert dpnp.atleast_1d(3).shape == (1,) - assert dpnp.atleast_1d(3j).shape == (1,) - assert dpnp.atleast_1d(3.0).shape == (1,) - assert dpnp.atleast_1d([[2, 3], [4, 5]]).shape == (2, 2) - class TestRollaxis: data = [ @@ -758,13 +752,6 @@ def test_3D_array(self): desired = [a, b] assert_array_equal(res, desired) - def test_r2array(self): - """Test to make sure equivalent Travis O's r2array function""" - assert dpnp.atleast_2d(3).shape == (1, 1) - assert dpnp.atleast_2d([3j, 1]).shape == (1, 2) - array = dpnp.atleast_2d([[[3, 1], [4, 5]], [[3, 5], [1, 2]]]) - assert array.shape == (2, 2, 2) - class TestAtleast3d: def test_0D_array(self): From 45da608b81ade3f64e7f3dc423369c473ebe60eb Mon Sep 17 00:00:00 2001 From: Natalia Polina Date: Thu, 12 Oct 2023 11:26:48 -0500 Subject: [PATCH 3/3] address comments --- dpnp/dpnp_iface_manipulation.py | 11 ++++++----- tests/skipped_tests.tbl | 4 ---- tests/skipped_tests_gpu.tbl | 4 ---- .../third_party/cupy/manipulation_tests/test_dims.py | 3 +++ 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/dpnp/dpnp_iface_manipulation.py b/dpnp/dpnp_iface_manipulation.py index c8e71e94a1b8..18fb93279764 100644 --- a/dpnp/dpnp_iface_manipulation.py +++ b/dpnp/dpnp_iface_manipulation.py @@ -129,7 +129,8 @@ def atleast_1d(*arys): Parameters ---------- arys : {dpnp.ndarray, usm_ndarray} - One or more input arrays. + One or more array-like sequences. Arrays that already have one or more + dimensions are preserved. Returns ------- @@ -167,7 +168,7 @@ def atleast_1d(*arys): for ary in arys: if not dpnp.is_supported_array_type(ary): raise TypeError( - "All arrays must be any of supported type, " + "Each input array must be any of supported type, " f"but got {type(ary)}" ) if ary.ndim == 0: @@ -224,7 +225,7 @@ def atleast_2d(*arys): for ary in arys: if not dpnp.is_supported_array_type(ary): raise TypeError( - "All arrays must be any of supported type, " + "Each input array must be any of supported type, " f"but got {type(ary)}" ) if ary.ndim == 0: @@ -242,7 +243,7 @@ def atleast_2d(*arys): return res -def atleast_3d(*arys, device=None, usm_type=None, sycl_queue=None): +def atleast_3d(*arys): """ View inputs as arrays with at least three dimensions. @@ -287,7 +288,7 @@ def atleast_3d(*arys, device=None, usm_type=None, sycl_queue=None): for ary in arys: if not dpnp.is_supported_array_type(ary): raise TypeError( - "All arrays must be any of supported type, " + "Each input array must be any of supported type, " f"but got {type(ary)}" ) if ary.ndim == 0: diff --git a/tests/skipped_tests.tbl b/tests/skipped_tests.tbl index 437f38353924..b553b449dd50 100644 --- a/tests/skipped_tests.tbl +++ b/tests/skipped_tests.tbl @@ -433,10 +433,6 @@ tests/third_party/cupy/logic_tests/test_comparison.py::TestArrayEqual::test_arra tests/third_party/cupy/logic_tests/test_comparison.py::TestArrayEqual::test_array_equal_is_equal tests/third_party/cupy/logic_tests/test_comparison.py::TestArrayEqual::test_array_equal_not_equal -tests/third_party/cupy/manipulation_tests/test_dims.py::TestDims::test_atleast_1d1 -tests/third_party/cupy/manipulation_tests/test_dims.py::TestDims::test_atleast_2d1 -tests/third_party/cupy/manipulation_tests/test_dims.py::TestDims::test_atleast_3d1 - tests/third_party/cupy/manipulation_tests/test_dims.py::TestBroadcast_param_0_{shapes=[(), ()]}::test_broadcast tests/third_party/cupy/manipulation_tests/test_dims.py::TestBroadcast_param_0_{shapes=[(), ()]}::test_broadcast_arrays tests/third_party/cupy/manipulation_tests/test_dims.py::TestBroadcast_param_10_{shapes=[(0, 1, 1, 0, 3), (5, 2, 0, 1, 0, 0, 3), (2, 1, 0, 0, 0, 3)]}::test_broadcast diff --git a/tests/skipped_tests_gpu.tbl b/tests/skipped_tests_gpu.tbl index 6bc6289d87db..e36491861a48 100644 --- a/tests/skipped_tests_gpu.tbl +++ b/tests/skipped_tests_gpu.tbl @@ -572,10 +572,6 @@ tests/third_party/cupy/logic_tests/test_comparison.py::TestArrayEqual::test_arra tests/third_party/cupy/logic_tests/test_comparison.py::TestArrayEqual::test_array_equal_is_equal tests/third_party/cupy/logic_tests/test_comparison.py::TestArrayEqual::test_array_equal_not_equal -tests/third_party/cupy/manipulation_tests/test_dims.py::TestDims::test_atleast_1d1 -tests/third_party/cupy/manipulation_tests/test_dims.py::TestDims::test_atleast_2d1 -tests/third_party/cupy/manipulation_tests/test_dims.py::TestDims::test_atleast_3d1 - tests/third_party/cupy/manipulation_tests/test_dims.py::TestBroadcast_param_0_{shapes=[(), ()]}::test_broadcast tests/third_party/cupy/manipulation_tests/test_dims.py::TestBroadcast_param_0_{shapes=[(), ()]}::test_broadcast_arrays tests/third_party/cupy/manipulation_tests/test_dims.py::TestBroadcast_param_10_{shapes=[(0, 1, 1, 0, 3), (5, 2, 0, 1, 0, 0, 3), (2, 1, 0, 0, 0, 3)]}::test_broadcast diff --git a/tests/third_party/cupy/manipulation_tests/test_dims.py b/tests/third_party/cupy/manipulation_tests/test_dims.py index d0e815e3f0a2..232025c3287d 100644 --- a/tests/third_party/cupy/manipulation_tests/test_dims.py +++ b/tests/third_party/cupy/manipulation_tests/test_dims.py @@ -18,6 +18,7 @@ def check_atleast(self, func, xp): f = numpy.float32(1) return func(a, b, c, d, e, f) + @pytest.mark.skip(reason="Scalar input is not supported") @testing.numpy_cupy_array_equal() def test_atleast_1d1(self, xp): return self.check_atleast(xp.atleast_1d, xp) @@ -27,6 +28,7 @@ def test_atleast_1d2(self, xp): a = testing.shaped_arange((1, 3, 2), xp) return xp.atleast_1d(a) + @pytest.mark.skip(reason="Scalar input is not supported") @testing.numpy_cupy_array_equal() def test_atleast_2d1(self, xp): return self.check_atleast(xp.atleast_2d, xp) @@ -36,6 +38,7 @@ def test_atleast_2d2(self, xp): a = testing.shaped_arange((1, 3, 2), xp) return xp.atleast_2d(a) + @pytest.mark.skip(reason="Scalar input is not supported") @testing.numpy_cupy_array_equal() def test_atleast_3d1(self, xp): return self.check_atleast(xp.atleast_3d, xp)