|
43 | 43 | 'diag_indices_from', 'hanning', 'hamming', 'blackman', 'flip', 'flipud', 'fliplr',
|
44 | 44 | 'hypot', 'bitwise_and', 'bitwise_xor', 'bitwise_or', 'rad2deg', 'deg2rad', 'unique', 'lcm',
|
45 | 45 | 'tril', 'identity', 'take', 'ldexp', 'vdot', 'inner', 'outer',
|
46 |
| - 'equal', 'not_equal', 'greater', 'less', 'greater_equal', 'less_equal', 'rot90', 'einsum', |
| 46 | + 'equal', 'not_equal', 'greater', 'less', 'greater_equal', 'less_equal', 'roll', 'rot90', 'einsum', |
47 | 47 | 'true_divide', 'nonzero', 'quantile', 'percentile', 'shares_memory', 'may_share_memory',
|
48 | 48 | 'diff', 'ediff1d', 'resize', 'polyval', 'nan_to_num', 'isnan', 'isinf', 'isposinf', 'isneginf', 'isfinite',
|
49 | 49 | 'where', 'bincount', 'pad', 'cumsum']
|
@@ -6307,6 +6307,72 @@ def less_equal(x1, x2, out=None):
|
6307 | 6307 | _npi.greater_equal_scalar, out)
|
6308 | 6308 |
|
6309 | 6309 |
|
| 6310 | +@set_module('mxnet.ndarray.numpy') |
| 6311 | +def roll(a, shift, axis=None): |
| 6312 | + """ |
| 6313 | + Roll array elements along a given axis. |
| 6314 | +
|
| 6315 | + Elements that roll beyond the last position are re-introduced at |
| 6316 | + the first. |
| 6317 | +
|
| 6318 | + Parameters |
| 6319 | + ---------- |
| 6320 | + a : ndarray |
| 6321 | + Input array. |
| 6322 | + shift : int or tuple of ints |
| 6323 | + The number of places by which elements are shifted. If a tuple, |
| 6324 | + then `axis` must be a tuple of the same size, and each of the |
| 6325 | + given axes is shifted by the corresponding number. If an int |
| 6326 | + while `axis` is a tuple of ints, then the same value is used for |
| 6327 | + all given axes. |
| 6328 | + axis : int or tuple of ints, optional |
| 6329 | + Axis or axes along which elements are shifted. By default, the |
| 6330 | + array is flattened before shifting, after which the original |
| 6331 | + shape is restored. |
| 6332 | +
|
| 6333 | + Returns |
| 6334 | + ------- |
| 6335 | + res : ndarray |
| 6336 | + Output array, with the same shape as `a`. |
| 6337 | +
|
| 6338 | + Notes |
| 6339 | + ----- |
| 6340 | + Supports rolling over multiple dimensions simultaneously. |
| 6341 | +
|
| 6342 | + Examples |
| 6343 | + -------- |
| 6344 | + >>> x = np.arange(10) |
| 6345 | + >>> np.roll(x, 2) |
| 6346 | + array([8., 9., 0., 1., 2., 3., 4., 5., 6., 7.]) |
| 6347 | + >>> np.roll(x, -2) |
| 6348 | + array([2., 3., 4., 5., 6., 7., 8., 9., 0., 1.]) |
| 6349 | +
|
| 6350 | + >>> x2 = np.reshape(x, (2,5)) |
| 6351 | + >>> x2 |
| 6352 | + array([[0., 1., 2., 3., 4.], |
| 6353 | + [5., 6., 7., 8., 9.]]) |
| 6354 | + >>> np.roll(x2, 1) |
| 6355 | + array([[9., 0., 1., 2., 3.], |
| 6356 | + [4., 5., 6., 7., 8.]]) |
| 6357 | + >>> np.roll(x2, -1) |
| 6358 | + array([[1., 2., 3., 4., 5.], |
| 6359 | + [6., 7., 8., 9., 0.]]) |
| 6360 | + >>> np.roll(x2, 1, axis=0) |
| 6361 | + array([[5., 6., 7., 8., 9.], |
| 6362 | + [0., 1., 2., 3., 4.]]) |
| 6363 | + >>> np.roll(x2, -1, axis=0) |
| 6364 | + array([[5., 6., 7., 8., 9.], |
| 6365 | + [0., 1., 2., 3., 4.]]) |
| 6366 | + >>> np.roll(x2, 1, axis=1) |
| 6367 | + array([[4., 0., 1., 2., 3.], |
| 6368 | + [9., 5., 6., 7., 8.]]) |
| 6369 | + >>> np.roll(x2, -1, axis=1) |
| 6370 | + array([[1., 2., 3., 4., 0.], |
| 6371 | + [6., 7., 8., 9., 5.]]) |
| 6372 | + """ |
| 6373 | + return _api_internal.roll(a, shift, axis) |
| 6374 | + |
| 6375 | + |
6310 | 6376 | @set_module('mxnet.ndarray.numpy')
|
6311 | 6377 | def rot90(m, k=1, axes=(0, 1)):
|
6312 | 6378 | """
|
@@ -6350,7 +6416,7 @@ def rot90(m, k=1, axes=(0, 1)):
|
6350 | 6416 | [[5., 7.],
|
6351 | 6417 | [4., 6.]]])
|
6352 | 6418 | """
|
6353 |
| - return _npi.rot90(m, k=k, axes=axes) |
| 6419 | + return _api_internal.rot90(m, k, axes) |
6354 | 6420 |
|
6355 | 6421 |
|
6356 | 6422 | @set_module('mxnet.ndarray.numpy')
|
|
0 commit comments