Welcome to the analytics utilities team. This module computes rolling window statistics over a list of numbers: moving averages and rolling maxima.
Welcome to the analytics utilities team. This module computes rolling window statistics over a list of numbers: moving averages and rolling maxima.
There is one ticket below. Fix as much of it as you can in 35 minutes. Its checks are graded one by one, so each part you get working counts even if the rest is not done.
moving_average returns real-valued averages (no truncation).rolling_max returns the maximum of each window.Rolling statistics are off. The sliding window yields one element too few (size minus one), moving_average floors each result with integer division, and rolling_max computes a minimum instead of a maximum.
moving_average([1, 2, 3, 4], 2) is [1.5, 2.5, 3.5] (real-valued).rolling_max([1, 3, 2, 5, 4], 2) is [3, 3, 5, 5].rolling_max.Keep the public functions moving_average and rolling_max.
windows.py (the windows generator) and stats.py (moving_average and rolling_max). The shipped regression tests are in tests/visible/; every one of them fails until the bugs are fixed.pytest tests/visible.Adapted from treasure567/bloomberg-practice (round-1/cobalt @ 8de07d5), used with the author's permission.
Visible test command
pytest tests/visibleThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
rolling-window-averages-and-maxima
Changes under src/ are evaluated.