Skip to content

Commit 068f65c

Browse files
Merge pull request #1140 from IntelPython/doc-clean-up-fix-gh-1115
Closes gh-1115, fixes docstring's Returns sections
2 parents ede58f6 + d0d4bf1 commit 068f65c

File tree

9 files changed

+339
-137
lines changed

9 files changed

+339
-137
lines changed

dpctl/tensor/_copy_utils.py

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,29 @@ def from_numpy(np_ary, device=None, usm_type="device", sycl_queue=None):
108108
from_numpy(arg, device=None, usm_type="device", sycl_queue=None)
109109
110110
Creates :class:`dpctl.tensor.usm_ndarray` from instance of
111-
`numpy.ndarray`.
111+
:class:`numpy.ndarray`.
112112
113113
Args:
114-
arg: An instance of input `numpy.ndarray`
115-
device: array API specification of device where the output array
116-
is created
117-
usm_type: The requested USM allocation type for the output array
118-
sycl_queue: a :class:`dpctl.SyclQueue` instance that determines
119-
output array allocation device as well as placement of data
120-
movement operation. The `device` and `sycl_queue` arguments
114+
arg (array-like): An instance of input convertible to
115+
:class:`numpy.ndarray`
116+
device (object): array API specification of device where the
117+
output array is created. Device can be specified by a
118+
a filter selector string, an instance of
119+
:class:`dpctl.SyclDevice`, an instance of
120+
:class:`dpctl.SyclQueue`, an instance of
121+
:class:`dpctl.tensor.Device`. If the value is `None`,
122+
returned array is created on the default-selected device.
123+
Default: `None`.
124+
usm_type (str): The requested USM allocation type for the
125+
output array. Recognized values are `"device"`, `"shared"`,
126+
or `"host"`.
127+
sycl_queue (:class:`dpctl.SyclQueue`, optional):
128+
A SYCL queue that determines output array allocation device
129+
as well as execution placement of data movement operations.
130+
The `device` and `sycl_queue` arguments
121131
are equivalent. Only one of them should be specified. If both
122132
are provided, they must be consistent and result in using the
123-
same execution queue.
133+
same execution queue. Default: `None`.
124134
125135
The returned array has the same shape, and the same data type kind.
126136
If the device does not support the data type of input array, a
@@ -137,12 +147,15 @@ def to_numpy(usm_ary):
137147
to_numpy(usm_ary)
138148
139149
Copies content of :class:`dpctl.tensor.usm_ndarray` instance `usm_ary`
140-
into `numpy.ndarray` instance of the same shape and same data type.
150+
into :class:`numpy.ndarray` instance of the same shape and same data type.
141151
142152
Args:
143-
usm_ary: An instance of :class:`dpctl.tensor.usm_ndarray`
153+
usm_ary (usm_ndarray):
154+
Input array
144155
Returns:
145-
An instance of `numpy.ndarray` populated with content of `usm_ary`.
156+
:class:`numpy.ndarray`:
157+
An instance of :class:`numpy.ndarray` populated with content of
158+
`usm_ary`
146159
"""
147160
return _copy_to_numpy(usm_ary)
148161

@@ -152,18 +165,24 @@ def asnumpy(usm_ary):
152165
asnumpy(usm_ary)
153166
154167
Copies content of :class:`dpctl.tensor.usm_ndarray` instance `usm_ary`
155-
into `numpy.ndarray` instance of the same shape and same data type.
168+
into :class:`numpy.ndarray` instance of the same shape and same data
169+
type.
156170
157171
Args:
158-
usm_ary: An instance of :class:`dpctl.tensor.usm_ndarray`
172+
usm_ary (usm_ndarray):
173+
Input array
159174
Returns:
160-
An instance of `numpy.ndarray` populated with content of `usm_ary`.
175+
:class:`numpy.ndarray`:
176+
An instance of :class:`numpy.ndarray` populated with content
177+
of `usm_ary`
161178
"""
162179
return _copy_to_numpy(usm_ary)
163180

164181

165182
class Dummy:
166-
"Helper class with specified __sycl_usm_array_interface__ attribute"
183+
"""
184+
Helper class with specified ``__sycl_usm_array_interface__`` attribute
185+
"""
167186

168187
def __init__(self, iface):
169188
self.__sycl_usm_array_interface__ = iface
@@ -263,10 +282,20 @@ def _copy_from_usm_ndarray_to_usm_ndarray(dst, src):
263282

264283

265284
def copy(usm_ary, order="K"):
266-
"""
267-
Creates a copy of given instance of `usm_ndarray`.
285+
"""copy(ary, order="K")
286+
287+
Creates a copy of given instance of :class:`dpctl.tensor.usm_ndarray`.
288+
289+
Args:
290+
ary (usm_ndarray):
291+
Input array.
292+
order ({"C", "F", "A", "K"}, optional):
293+
Controls the memory layout of the output array.
294+
Returns:
295+
usm_ndarray:
296+
A copy of the input array.
268297
269-
Memory layour of the copy is controlled by `order` keyword,
298+
Memory layout of the copy is controlled by `order` keyword,
270299
following NumPy's conventions. The `order` keywords can be
271300
one of the following:
272301
@@ -325,10 +354,31 @@ def copy(usm_ary, order="K"):
325354

326355

327356
def astype(usm_ary, newdtype, order="K", casting="unsafe", copy=True):
328-
"""
329-
astype(usm_array, new_dtype, order="K", casting="unsafe", copy=True)
357+
""" astype(array, new_dtype, order="K", casting="unsafe", \
358+
copy=True)
359+
360+
Returns a copy of the :class:`dpctl.tensor.usm_ndarray`, cast to a
361+
specified type.
330362
331-
Returns a copy of the array, cast to a specified type.
363+
Args:
364+
array (usm_ndarray):
365+
An input array.
366+
new_dtype (dtype):
367+
The data type of the resulting array.
368+
order ({"C", "F", "A", "K"}, optional):
369+
Controls memory layout of the resulting array if a copy
370+
is returned.
371+
casting ({'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional):
372+
Controls what kind of data casting may occur. Please see
373+
:meth:`numpy.ndarray.astype` for description of casting modes.
374+
copy (bool, optional):
375+
By default, `astype` always returns a newly allocated array.
376+
If this keyword is set to `False`, a view of the input array
377+
may be returned when possible.
378+
379+
Returns:
380+
usm_ndarray:
381+
An array with requested data type.
332382
333383
A view can be returned, if possible, when `copy=False` is used.
334384
"""

0 commit comments

Comments
 (0)