question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

An alternative solution for Q.76

See original GitHub issue
  1. 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:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
rougiercommented, Dec 15, 2021

Perfect! If you can make (individual) PR, that would be fantastic.

1reaction
FirefoxMetzgercommented, Dec 11, 2021

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found