np.roll improvements
See original GitHub issueTwo quick suggestions:
- add an
inplace={False|True}
(or perhaps justout
, like for the ufuncs). - support shifting along multiple axes simultaneously: either allow
shift
to be an array-like of length equal to the array’s ndim, or allow passing two sequences,shift
andaxis
, of the same length (or allow both).
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Fast numpy roll - python - Stack Overflow
Further improvement. For repeated usages, you are better off creating the full linear indices and then using np.take to extract the rolled ......
Read more >numpy.roll — NumPy v1.24 Manual
Supports rolling over multiple dimensions simultaneously. Examples. >>> x = np.arange(10) >>> np.roll(x, 2) array([8, 9, 0, 1, 2, 3, 4, 5, 6, ......
Read more >ncempy.algo package - openNCEM Documentation
Returns: List of filtered points, two column array. Return type: np.ndarray. ncempy.algo.distortion. optimize_center ...
Read more >numpy.roll() in Python - GeeksforGeeks
roll () function rolls array elements along the specified axis. Basically what happens is that elements of the input array are being shifted....
Read more >Optimizing very simple piece of “Game of Life” code by taking ...
Benchmarking this we see a significant improvement in speed (x 180): ... N = np.roll(Z,1,axis=1) + np.roll(Z,-1,axis=1) + np.roll(Z,1,axis=0) + np.roll(Z,-1 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there API that I can use an array as a shift register ? For example,
This pattern is very common in real time signal process. I really hope numpy can have such API to reduce unnecessary memory copy.
At least in the case where the shift is small compared to the size of the array (and I expect shifts by 1 to be quite common),
roll
could at least work by allocating a small array equal to the number of shifted elements as temporary storage and do the shifting in place.