[MISC] Add unit tests for TensorRingBuffer.#2843
Open
yeezhouyi wants to merge 1 commit into
Open
Conversation
Add 20 unit tests covering initialization (defaults, external buffer/idx, shape/dtype validation), data flow (set, get, at, rotate, clone), slicing (getitem with int/slice/tuple), edge cases (wraparound, copy semantics, invalid key), and multi-dimensional tensors. All tests follow the production rotate-then-set pattern used by the sensor pipeline, ensuring they match real usage semantics. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Collaborator
|
We do not have unit test in Genesis, only integration test. Why do you think it is relevant to add unit test for the TensorRingBuffer specifically? |
Author
|
Thanks for the feedback! I understand that Genesis uses integration tests, and I respect that convention. The reason I added dedicated tests for TensorRingBuffer is that it's a core data structure shared across the entire sensor pipeline, with subtle semantics around memory sharing, view vs clone behavior, and index wraparound that integration tests can't easily catch. For example, the __getitem__ slice behavior can silently produce wrong views for multi-dimensional tensors — a kind of bug that wouldn't surface as a wrong sensor reading but could cause hard-to-debug memory corruption in long-running simulations. That said, I'm happy to adapt the tests to match the project style if you prefer. Let me know what you think!
|
Collaborator
I don't think a bug that wouldn't surface as a wrong sensor reading is worth fixing. Since it is basically our only requirement today for this class. |
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
TensorRingBufferingenesis/utils/ring_buffer.py, covering initialization, data flow, rotation, relative indexing, copy semantics, slicing, cloning, wraparound, and multidimensional access.@pytest.mark.required.Test plan
pytest tests/test_utils.py -k ring_buffer -vpasses.