test: Add a unit test for the usage of restrict_to and restriction_idx_key in select_in_dataset of GoldSelector - #322
Merged
Yann-CV merged 3 commits intoSep 1, 2026
Conversation
Yann-CV
requested changes
Sep 1, 2026
Yann-CV
left a comment
Contributor
There was a problem hiding this comment.
Thanks a lot for your contribution! Just missing 1 test and we are good!
Yann-CV
approved these changes
Sep 1, 2026
Yann-CV
left a comment
Contributor
There was a problem hiding this comment.
Great! Thanks your contribution!
Hope to review you again soon!
Contributor
There was a problem hiding this comment.
Pull request overview
Adds targeted unit tests to ensure GoldSelector.select_in_dataset() (and select_in_table()) correctly forward and apply the restrict_to and restriction_idx_key parameters, improving direct coverage for behavior previously only exercised indirectly.
Changes:
- Add a
select_in_datasettest that verifies selection is constrained to a providedrestrict_topool. - Add a
select_in_tabletest that verifies the full source table is preserved while selection is constrained torestrict_to. - Add tests verifying
restriction_idx_keyfiltering and that aValueErroris raised whenselect_sizeexceeds the restricted pool size.
Suppressed comments (1)
tests/test_select.py:718
- Test name says "select_from_table" but the test calls GoldSelector.select_in_table; renaming to "select_in_table" keeps naming consistent with the rest of the suite and the API surface being tested.
def test_select_from_table_with_restrict_to(self):
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Yann-CV
reviewed
Sep 1, 2026
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.
Closes #310
Tests added
test_select_in_dataset_with_restrict_to — verifies selection is limited to the idx_vector values passed in restrict_to, not the full dataset.
test_select_in_dataset_with_restriction_idx_key — verifies filtering happens on a custom key (idx) instead of the default idx_vector, and that idx/idx_vector mapping stays correct for selected samples.
test_select_in_dataset_with_restrict_to_exceeding_size — verifies a ValueError is raised when select_size exceeds the size of the restricted pool (not the full dataset).
All 61 tests in tests/test_select.py pass.
Summary by cubic
Adds unit test coverage for
restrict_toandrestriction_idx_keyinGoldSelector.select_in_datasetandselect_in_table, closing #310.restrict_topool rather than the full dataset for both methods.restriction_idx_keyand keeps theidx/idx_vectormapping correct for selected samples.ValueErroris raised whenselect_sizeexceeds the restricted pool size.select_in_tablepreserves the full source table while marking only the restricted pool.tests/test_select.pypass.Written for commit 77a0d7c. Summary will update on new commits.