Repository navigation
Fix sliding window accumulator eviction order - #1640
Open
tenth-package0 wants to merge 2 commits into
Open
tenth-package0 wants to merge 2 commits into
tenth-package0 wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix the eviction order in
SlidingWindowAccumulator. With a window size of 3, adding[1, 2, 3, 4]currently leaves[1, 2, 4]and returns a mean of7 / 3, instead of retaining the latest three values and returning3.Keep the replacement index at zero while the buffer fills, then advance it only when replacing an entry. Use modular index advancement to make wraparound explicit. Reject non-positive capacities with a clear
ValueErrorinstead of failing later with an index error.Add regression coverage for the first eviction, an empty window, invalid capacities, capacity one, partial windows, and repeated wraparound at several capacities. Register the test in the Python CMake test list.
Validation
python -m open_spiel.python.utils.stats_test: all 8 tests pass on Python 3.12.14; the original implementation fails the eviction regression cases.ruff check open_spiel/python/utils/stats.py open_spiel/python/utils/stats_test.py: passed.pyink --check open_spiel/python/utils/stats_test.py: passed.git diff --check: passed.The full C++/Python integration suite was not run locally.