@@ -3129,9 +3129,9 @@ def resize(a, new_shape):
3129
3129
Returns
3130
3130
-------
3131
3131
out : dpnp.ndarray
3132
- The new array is formed from the data in the old array, repeated
3133
- if necessary to fill out the required number of elements. The
3134
- data are repeated iterating over the array in C-order.
3132
+ The new array is formed from the data in the old array, repeated if
3133
+ necessary to fill out the required number of elements. The data are
3134
+ repeated iterating over the array in C-order.
3135
3135
3136
3136
See Also
3137
3137
--------
@@ -3146,8 +3146,10 @@ def resize(a, new_shape):
3146
3146
be used. In most other cases either indexing (to reduce the size) or
3147
3147
padding (to increase the size) may be a more appropriate solution.
3148
3148
3149
- Warning: This functionality does **not** consider axes separately,
3150
- i.e. it does not apply interpolation/extrapolation.
3149
+ Warning
3150
+ -------
3151
+ This functionality does **not** consider axes separately, i.e. it does not
3152
+ apply interpolation/extrapolation.
3151
3153
It fills the return array with the required number of elements, iterating
3152
3154
over `a` in C-order, disregarding axes (and cycling back from the start if
3153
3155
the new shape is larger). This functionality is therefore not suitable to
@@ -3187,7 +3189,8 @@ def resize(a, new_shape):
3187
3189
# First case must zero fill. The second would have repeats == 0.
3188
3190
return dpnp .zeros_like (a , shape = new_shape )
3189
3191
3190
- repeats = - (- new_size // a_size ) # ceil division
3192
+ # ceiling division without negating new_size
3193
+ repeats = (new_size + a_size - 1 ) // a_size
3191
3194
a = dpnp .concatenate ((dpnp .ravel (a ),) * repeats )[:new_size ]
3192
3195
3193
3196
return a .reshape (new_shape )
0 commit comments