Skip to content

Commit acb5d25

Browse files
authored
improve coverage dpnp_iface_manipulation.py (#2175)
* improve coverage dpnp_iface_manipulation.py * add a new test * update docstring tranpose
1 parent 2987585 commit acb5d25

File tree

3 files changed

+192
-189
lines changed

3 files changed

+192
-189
lines changed

dpnp/dpnp_iface_manipulation.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3848,13 +3848,14 @@ def transpose(a, axes=None):
38483848
----------
38493849
a : {dpnp.ndarray, usm_ndarray}
38503850
Input array.
3851-
axes : None, tuple or list of ints, optional
3851+
axes : {None, tuple or list of ints}, optional
38523852
If specified, it must be a tuple or list which contains a permutation
38533853
of [0, 1, ..., N-1] where N is the number of axes of `a`.
38543854
The `i`'th axis of the returned array will correspond to the axis
38553855
numbered ``axes[i]`` of the input. If not specified or ``None``,
38563856
defaults to ``range(a.ndim)[::-1]``, which reverses the order of
38573857
the axes.
3858+
Default: ``None``.
38583859
38593860
Returns
38603861
-------
@@ -3894,18 +3895,13 @@ def transpose(a, axes=None):
38943895
38953896
"""
38963897

3897-
if isinstance(a, dpnp_array):
3898-
array = a
3899-
elif isinstance(a, dpt.usm_ndarray):
3900-
array = dpnp_array._create_from_usm_ndarray(a)
3901-
else:
3902-
raise TypeError(
3903-
f"An array must be any of supported type, but got {type(a)}"
3904-
)
3898+
dpnp.check_supported_arrays_type(a)
3899+
if isinstance(a, dpt.usm_ndarray):
3900+
a = dpnp_array._create_from_usm_ndarray(a)
39053901

39063902
if axes is None:
3907-
return array.transpose()
3908-
return array.transpose(*axes)
3903+
return a.transpose()
3904+
return a.transpose(*axes)
39093905

39103906

39113907
permute_dims = transpose # permute_dims is an alias for transpose

0 commit comments

Comments
 (0)