Skip to content

Commit dd1da6b

Browse files
authored
Edit docstrings for tile and repeat, fix "usm_narray" typos (#1629)
* Improves `tile` docstring * Improves `repeat` docstring * Fixed typos in `angle` and `reciprocal` docstrings * Fixed typos in docstrings for `permute_dims, `moveaxis`, and `swapaxes` * Fixes typo and grammar in `nonzero` docstring * Fixes a typo in `populate_params` in `blackscholes.pyx` example * Change to `broadcast-compatible` per PR review by @oleksandr-pavlyk
1 parent 7ac9ff2 commit dd1da6b

File tree

4 files changed

+39
-26
lines changed

4 files changed

+39
-26
lines changed

dpctl/tensor/_elementwise_funcs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,7 +2160,7 @@
21602160
Default: "K".
21612161
21622162
Returns:
2163-
usm_narray:
2163+
usm_ndarray:
21642164
An array containing the element-wise reciprocals.
21652165
The returned array has a floating-point data type determined
21662166
by the Type Promotion Rules.
@@ -2195,7 +2195,7 @@
21952195
Default: "K".
21962196
21972197
Returns:
2198-
usm_narray:
2198+
usm_ndarray:
21992199
An array containing the element-wise phase angles.
22002200
The returned array has a floating-point data type determined
22012201
by the Type Promotion Rules.

dpctl/tensor/_indexing_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def nonzero(arr):
326326
327327
Return the indices of non-zero elements.
328328
329-
Returns the tuple of usm_narrays, one for each dimension
329+
Returns a tuple of usm_ndarrays, one for each dimension
330330
of `arr`, containing the indices of the non-zero elements
331331
in that dimension. The values of `arr` are always tested in
332332
row-major, C-style order.

dpctl/tensor/_manipulation_functions.py

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def permute_dims(X, /, axes):
9595
`(0,1,...,N-1)` where `N` is the number of axes (dimensions)
9696
of `x`.
9797
Returns:
98-
usm_narray:
98+
usm_ndarray:
9999
An array with permuted axes.
100100
The returned array must has the same data type as `x`,
101101
is created on the same device as `x` and has the same USM allocation
@@ -646,7 +646,7 @@ def moveaxis(X, source, destination, /):
646646
in the half-open interval `[-N, N)`.
647647
648648
Returns:
649-
usm_narray:
649+
usm_ndarray:
650650
Array with moved axes.
651651
The returned array must has the same data type as `x`,
652652
is created on the same device as `x` and has the same
@@ -693,7 +693,7 @@ def swapaxes(X, axis1, axis2):
693693
a valid `axis` must be in the half-open interval `[-N, N)`.
694694
695695
Returns:
696-
usm_narray:
696+
usm_ndarray:
697697
Array with swapped axes.
698698
The returned array must has the same data type as `x`,
699699
is created on the same device as `x` and has the same USM
@@ -717,32 +717,38 @@ def swapaxes(X, axis1, axis2):
717717
def repeat(x, repeats, /, *, axis=None):
718718
"""repeat(x, repeats, axis=None)
719719
720-
Repeat elements of an array.
720+
Repeat elements of an array on a per-element basis.
721721
722722
Args:
723723
x (usm_ndarray): input array
724724
725725
repeats (Union[int, Sequence[int, ...], usm_ndarray]):
726726
The number of repetitions for each element.
727-
`repeats` is broadcast to fit the shape of the given axis.
727+
728+
`repeats` must be broadcast-compatible with `N` where `N` is
729+
`prod(x.shape)` if `axis` is `None` and `x.shape[axis]`
730+
otherwise.
731+
728732
If `repeats` is an array, it must have an integer data type.
729-
Otherwise, `repeats` must be a Python integer, tuple, list, or
730-
range.
733+
Otherwise, `repeats` must be a Python integer or sequence of
734+
Python integers (i.e., a tuple, list, or range).
731735
732736
axis (Optional[int]):
733737
The axis along which to repeat values. If `axis` is `None`, the
734-
function repeats elements of the flattened array.
735-
Default: `None`.
738+
function repeats elements of the flattened array. Default: `None`.
736739
737740
Returns:
738-
usm_narray:
739-
Array with repeated elements.
740-
The returned array must have the same data type as `x`, is created
741-
on the same device as `x` and has the same USM allocation type as
742-
`x`. If `axis` is `None`, the returned array is one-dimensional,
741+
usm_ndarray:
742+
output array with repeated elements.
743+
744+
If `axis` is `None`, the returned array is one-dimensional,
743745
otherwise, it has the same shape as `x`, except for the axis along
744746
which elements were repeated.
745747
748+
The returned array will have the same data type as `x`.
749+
The returned array will be located on the same device as `x` and
750+
have the same USM allocation type as `x`.
751+
746752
Raises:
747753
AxisError: if `axis` value is invalid.
748754
"""
@@ -937,21 +943,28 @@ def tile(x, repetitions, /):
937943
`repetitions`.
938944
939945
For `N` = len(`repetitions`) and `M` = len(`x.shape`):
940-
- if `M < N`, `x` will have `N - M` new axes prepended to its shape
941-
- if `M > N`, `repetitions` will have `M - N` new axes 1 prepended to it
946+
947+
* If `M < N`, `x` will have `N - M` new axes prepended to its shape
948+
* If `M > N`, `repetitions` will have `M - N` ones prepended to it
942949
943950
Args:
944951
x (usm_ndarray): input array
945952
946953
repetitions (Union[int, Tuple[int, ...]]):
947-
The number of repetitions for each dimension.
954+
The number of repetitions along each dimension of `x`.
948955
949956
Returns:
950-
usm_narray:
951-
Array with tiled elements.
952-
The returned array must have the same data type as `x`,
953-
is created on the same device as `x` and has the same USM
954-
allocation type as `x`.
957+
usm_ndarray:
958+
tiled output array.
959+
960+
The returned array will have rank `max(M, N)`. If `S` is the
961+
shape of `x` after prepending dimensions and `R` is
962+
`repetitions` after prepending ones, then the shape of the
963+
result will be `S[i] * R[i]` for each dimension `i`.
964+
965+
The returned array will have the same data type as `x`.
966+
The returned array will be located on the same device as `x` and
967+
have the same USM allocation type as `x`.
955968
"""
956969
if not isinstance(x, dpt.usm_ndarray):
957970
raise TypeError(f"Expected usm_ndarray type, got {type(x)}.")

examples/cython/usm_memory/blackscholes/blackscholes.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def populate_params(
135135
""" populate_params(params, pl, ph, sl, sh, tl, th, rl, rh, vl, vh, seed)
136136
137137
Args:
138-
params: usm_narray
138+
params: usm_ndarray
139139
Array of shape (n_opts, 5) to populate with price, strike, time to
140140
maturity, interest rate, volatility rate per option using uniform
141141
distribution with provided distribution parameters.

0 commit comments

Comments
 (0)