Skip to content

Commit 7d5b47a

Browse files
committed
address comments
1 parent 1e68bee commit 7d5b47a

File tree

4 files changed

+540
-528
lines changed

4 files changed

+540
-528
lines changed

dpnp/dpnp_iface_manipulation.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,7 @@ def pad(array, pad_width, mode="constant", **kwargs):
18481848
Parameters
18491849
----------
18501850
array : {dpnp.ndarray, usm_ndarray}
1851-
The array to pad.
1851+
The array of rank ``N`` to pad.
18521852
pad_width : {sequence, array_like, int}
18531853
Number of values padded to the edges of each axis.
18541854
``((before_1, after_1), ... (before_N, after_N))`` unique pad widths
@@ -1893,21 +1893,17 @@ def pad(array, pad_width, mode="constant", **kwargs):
18931893
Padding function, see Notes.
18941894
Default: ``"constant"``.
18951895
stat_length : {None, int, sequence of ints}, optional
1896-
Used in "maximum", "mean", and "minimum". Number of
1896+
Used in ``"maximum"``, ``"mean"``, and ``"minimum"``. Number of
18971897
values at edge of each axis used to calculate the statistic value.
1898-
18991898
``((before_1, after_1), ... (before_N, after_N))`` unique statistic
19001899
lengths for each axis.
1901-
19021900
``(before, after)`` or ``((before, after),)`` yields same before
19031901
and after statistic lengths for each axis.
1904-
19051902
``(stat_length,)`` or ``int`` is a shortcut for
19061903
``before = after = statistic`` length for all axes.
1907-
19081904
Default: ``None``, to use the entire axis.
19091905
constant_values : {sequence, scalar}, optional
1910-
Used in "constant". The values to set the padded values for each
1906+
Used in ``"constant"``. The values to set the padded values for each
19111907
axis.
19121908
``((before_1, after_1), ... (before_N, after_N))`` unique pad constants
19131909
for each axis.
@@ -1917,7 +1913,7 @@ def pad(array, pad_width, mode="constant", **kwargs):
19171913
``before = after = constant`` for all axes.
19181914
Default: ``0``.
19191915
end_values : {sequence, scalar}, optional
1920-
Used in "linear_ramp". The values used for the ending value of the
1916+
Used in ``"linear_ramp"``. The values used for the ending value of the
19211917
linear_ramp and that will form the edge of the padded array.
19221918
``((before_1, after_1), ... (before_N, after_N))`` unique end values
19231919
for each axis.
@@ -1927,9 +1923,9 @@ def pad(array, pad_width, mode="constant", **kwargs):
19271923
``before = after = constant`` for all axes.
19281924
Default: ``0``.
19291925
reflect_type : {"even", "odd"}, optional
1930-
Used in "reflect", and "symmetric". The "even" style is the
1926+
Used in ``"reflect"``, and ``"symmetric"``. The ``"even"`` style is the
19311927
default with an unaltered reflection around the edge value. For
1932-
the "odd" style, the extended part of the array is created by
1928+
the ``"odd"`` style, the extended part of the array is created by
19331929
subtracting the reflected values from two times the edge value.
19341930
Default: ``"even"``.
19351931

dpnp/dpnp_utils/dpnp_utils_pad.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ def _get_stats(padded, axis, width_pair, length_pair, stat_func):
216216
valid area in `padded` is considered.
217217
stat_func : function
218218
Function to compute statistic. The expected signature is
219-
``stat_func(x: ndarray, axis: int, keepdims: bool) -> ndarray``.
219+
``stat_func(x: dpnp.ndarray, axis: int, keepdims: bool) -> dpnp.ndarray``.
220220
221221
Returns
222222
-------
223-
left_stat, right_stat : ndarray
223+
left_stat, right_stat : dpnp.ndarray
224224
Calculated statistic for both sides of `padded`.
225225
226226
"""
@@ -642,6 +642,7 @@ def dpnp_pad(array, pad_width, mode="constant", **kwargs):
642642

643643
# compute indices for the iteration axes, and append a trailing
644644
# ellipsis to prevent 0d arrays decaying to scalars
645+
# TODO: replace with dpnp.ndindex when implemented
645646
inds = numpy.ndindex(view.shape[:-1])
646647
inds = (ind + (Ellipsis,) for ind in inds)
647648
for ind in inds:
@@ -744,7 +745,7 @@ def dpnp_pad(array, pad_width, mode="constant", **kwargs):
744745

745746
elif mode in {"reflect", "symmetric"}:
746747
method = kwargs.get("reflect_type", "even")
747-
include_edge = True if mode == "symmetric" else False
748+
include_edge = mode == "symmetric"
748749
for axis, (left_index, right_index) in zip(axes, pad_width):
749750
if array.shape[axis] == 1 and (left_index > 0 or right_index > 0):
750751
# Extending singleton dimension for 'reflect' is legacy
@@ -769,7 +770,7 @@ def dpnp_pad(array, pad_width, mode="constant", **kwargs):
769770
include_edge,
770771
)
771772

772-
elif mode == "wrap":
773+
else: # mode == "wrap":
773774
for axis, (left_index, right_index) in zip(axes, pad_width):
774775
roi = _view_roi(padded, original_area_slice, axis)
775776
original_period = padded.shape[axis] - right_index - left_index

0 commit comments

Comments
 (0)