ENH: Add a non-circular shift function

"Carlos Martin" <[email protected]>
Newsgroups gmane.comp.python.numeric.general
Message-ID <[email protected]>
Feature request: Add a non-circular shift function that is similar to [`numpy.roll`](https://numpy.org/doc/stable/reference/generated/numpy.roll.html) but, instead of wrapping elements around, replaces unoccupied entries with a specified fill value. Examples:

```
>>> import numpy as np
>>> a = np.arange(1, 6)
>>> a
array([1, 2, 3, 4, 5])
>>> np.shifted(a, 2)
array([0, 0, 1, 2, 3])
>>> np.shifted(a, -2)
array([3, 4, 5, 0, 0])
>>> a = np.arange(1, 10).reshape((3, 3))
>>> a
array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]])
>>> np.shifted(a, (1, -2), (0, 1))
array([[0, 0, 0],
       [3, 0, 0],
       [6, 0, 0]])
```

Prior discussion: https://github.com/numpy/numpy/issues/26220

Pull request: https://github.com/numpy/numpy/pull/29389
_______________________________________________
NumPy-Discussion mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/numpy-discussion.python.org
Member address: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.