Skip to content

Edit docstrings for tile and repeat, fix "usm_narray" typos #1629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dpctl/tensor/_elementwise_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2160,7 +2160,7 @@
Default: "K".

Returns:
usm_narray:
usm_ndarray:
An array containing the element-wise reciprocals.
The returned array has a floating-point data type determined
by the Type Promotion Rules.
Expand Down Expand Up @@ -2195,7 +2195,7 @@
Default: "K".

Returns:
usm_narray:
usm_ndarray:
An array containing the element-wise phase angles.
The returned array has a floating-point data type determined
by the Type Promotion Rules.
Expand Down
2 changes: 1 addition & 1 deletion dpctl/tensor/_indexing_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def nonzero(arr):

Return the indices of non-zero elements.

Returns the tuple of usm_narrays, one for each dimension
Returns a tuple of usm_ndarrays, one for each dimension
of `arr`, containing the indices of the non-zero elements
in that dimension. The values of `arr` are always tested in
row-major, C-style order.
Expand Down
57 changes: 35 additions & 22 deletions dpctl/tensor/_manipulation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def permute_dims(X, /, axes):
`(0,1,...,N-1)` where `N` is the number of axes (dimensions)
of `x`.
Returns:
usm_narray:
usm_ndarray:
An array with permuted axes.
The returned array must has the same data type as `x`,
is created on the same device as `x` and has the same USM allocation
Expand Down Expand Up @@ -646,7 +646,7 @@ def moveaxis(X, source, destination, /):
in the half-open interval `[-N, N)`.

Returns:
usm_narray:
usm_ndarray:
Array with moved axes.
The returned array must has the same data type as `x`,
is created on the same device as `x` and has the same
Expand Down Expand Up @@ -693,7 +693,7 @@ def swapaxes(X, axis1, axis2):
a valid `axis` must be in the half-open interval `[-N, N)`.

Returns:
usm_narray:
usm_ndarray:
Array with swapped axes.
The returned array must has the same data type as `x`,
is created on the same device as `x` and has the same USM
Expand All @@ -717,32 +717,38 @@ def swapaxes(X, axis1, axis2):
def repeat(x, repeats, /, *, axis=None):
"""repeat(x, repeats, axis=None)

Repeat elements of an array.
Repeat elements of an array on a per-element basis.

Args:
x (usm_ndarray): input array

repeats (Union[int, Sequence[int, ...], usm_ndarray]):
The number of repetitions for each element.
`repeats` is broadcast to fit the shape of the given axis.

`repeats` must be broadcast-compatible with `N` where `N` is
`prod(x.shape)` if `axis` is `None` and `x.shape[axis]`
otherwise.

If `repeats` is an array, it must have an integer data type.
Otherwise, `repeats` must be a Python integer, tuple, list, or
range.
Otherwise, `repeats` must be a Python integer or sequence of
Python integers (i.e., a tuple, list, or range).

axis (Optional[int]):
The axis along which to repeat values. If `axis` is `None`, the
function repeats elements of the flattened array.
Default: `None`.
function repeats elements of the flattened array. Default: `None`.

Returns:
usm_narray:
Array with repeated elements.
The returned array must have the same data type as `x`, is created
on the same device as `x` and has the same USM allocation type as
`x`. If `axis` is `None`, the returned array is one-dimensional,
usm_ndarray:
output array with repeated elements.

If `axis` is `None`, the returned array is one-dimensional,
otherwise, it has the same shape as `x`, except for the axis along
which elements were repeated.

The returned array will have the same data type as `x`.
The returned array will be located on the same device as `x` and
have the same USM allocation type as `x`.

Raises:
AxisError: if `axis` value is invalid.
"""
Expand Down Expand Up @@ -937,21 +943,28 @@ def tile(x, repetitions, /):
`repetitions`.

For `N` = len(`repetitions`) and `M` = len(`x.shape`):
- if `M < N`, `x` will have `N - M` new axes prepended to its shape
- if `M > N`, `repetitions` will have `M - N` new axes 1 prepended to it

* If `M < N`, `x` will have `N - M` new axes prepended to its shape
* If `M > N`, `repetitions` will have `M - N` ones prepended to it

Args:
x (usm_ndarray): input array

repetitions (Union[int, Tuple[int, ...]]):
The number of repetitions for each dimension.
The number of repetitions along each dimension of `x`.

Returns:
usm_narray:
Array with tiled elements.
The returned array must have the same data type as `x`,
is created on the same device as `x` and has the same USM
allocation type as `x`.
usm_ndarray:
tiled output array.

The returned array will have rank `max(M, N)`. If `S` is the
shape of `x` after prepending dimensions and `R` is
`repetitions` after prepending ones, then the shape of the
result will be `S[i] * R[i]` for each dimension `i`.

The returned array will have the same data type as `x`.
The returned array will be located on the same device as `x` and
have the same USM allocation type as `x`.
"""
if not isinstance(x, dpt.usm_ndarray):
raise TypeError(f"Expected usm_ndarray type, got {type(x)}.")
Expand Down
2 changes: 1 addition & 1 deletion examples/cython/usm_memory/blackscholes/blackscholes.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def populate_params(
""" populate_params(params, pl, ph, sl, sh, tl, th, rl, rh, vl, vh, seed)

Args:
params: usm_narray
params: usm_ndarray
Array of shape (n_opts, 5) to populate with price, strike, time to
maturity, interest rate, volatility rate per option using uniform
distribution with provided distribution parameters.
Expand Down