An alternative solution for Q.76
See original GitHub issue
- Consider a one-dimensional array Z, build a two-dimensional array whose first row is (Z[0],Z[1],Z[2]) and each subsequent row is shifted by 1 (last row should be (Z[-3],Z[-2],Z[-1]) (★★★) hint: from numpy.lib import stride_tricks
# Author: Joe Kington / Erik Rigtorp from numpy.lib import stride_tricks
def rolling(a, window): shape = (a.size - window + 1, window) strides = (a.strides[0], a.strides[0]) return stride_tricks.as_strided(a, shape=shape, strides=strides) Z = rolling(np.arange(10), 3) print(Z)
Same as the last issue, sliding_window_view is an easier function in NumPy. The new solution will be:
Z = np.arange(10)
print(sliding_window_view(Z, window_shape=(3)))
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Q. 76 Study more! A student group clai... [FREE SOLUTION]
A student group claims that first-year students at a university study hours per night during the school week. A skeptic suspects that they...
Read more >Q76 bus Route Map - College Pt 20 Av Via Francis Lewis
Use Moovit as a line Q76 bus tracker or a live MTA Bus bus tracker app and never miss your bus. Q76 -...
Read more >Solved Q76 Given the "normal" trigonometric form of the - Chegg
Question: Q76 Given the "normal" trigonometric form of the Fourier series coefficients for a waveform are daug = zero 4 =-5/n bu =...
Read more >Simplify: q/8=1.9 Tiger Algebra Solver
This solution deals with adding, subtracting and finding the least common multiple. Overview; Steps; Topics Terms and topics; Links Related links; Other ......
Read more >In ABC , if B = 76^∘ and C = 48^∘ , find A (in degrees). - Toppr
In △ABC, if ∠B=76∘ and ∠C=48∘, find ∠A (in degrees). Easy. Open in App Open_in_app. Solution. Verified by Toppr. Correct option is A) ......
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 Free
Top 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

Perfect! If you can make (individual) PR, that would be fantastic.
@Jeff1999 It is of course a matter of taste, but
.sum([-2, -1])might be easier to read than.sum(-1).sum(-1).Also, since you are omitting kwargs everywhere else, maybe
sliding_window_view(Z, (k, k))may be more consistent and shorter.