Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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 into
goldener-data:mainfrom
SHEKHAR-Y:fix/issue-310-restrict-to-tests
Sep 1, 2026
Merged

test: Add a unit test for the usage of restrict_to and restriction_idx_key in select_in_dataset of GoldSelector#322
Yann-CV merged 3 commits into
goldener-data:mainfrom
SHEKHAR-Y:fix/issue-310-restrict-to-tests

Conversation

@SHEKHAR-Y

@SHEKHAR-Y SHEKHAR-Y commented Sep 1, 2026

Copy link
Copy Markdown

Closes #310

  • select_in_dataset forwards restrict_to and restriction_idx_key to select_in_table, but neither parameter had dedicated unit test coverage in this file (only indirectly exercised via GoldSplitter).

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_to and restriction_idx_key in GoldSelector.select_in_dataset and select_in_table, closing #310.

  • Verifies selection is limited to the passed restrict_to pool rather than the full dataset for both methods.
  • Verifies filtering works on a custom restriction_idx_key and keeps the idx/idx_vector mapping correct for selected samples.
  • Verifies a ValueError is raised when select_size exceeds the restricted pool size.
  • Confirms select_in_table preserves the full source table while marking only the restricted pool.
  • Updates are test-only; all 61 tests in tests/test_select.py pass.

Written for commit 77a0d7c. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@Yann-CV Yann-CV left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your contribution! Just missing 1 test and we are good!

Comment thread tests/test_select.py Outdated
Comment thread tests/test_select.py
Comment thread tests/test_select.py
@SHEKHAR-Y
SHEKHAR-Y requested a review from Yann-CV September 1, 2026 16:29

@Yann-CV Yann-CV left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks your contribution!

Hope to review you again soon!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_dataset test that verifies selection is constrained to a provided restrict_to pool.
  • Add a select_in_table test that verifies the full source table is preserved while selection is constrained to restrict_to.
  • Add tests verifying restriction_idx_key filtering and that a ValueError is raised when select_size exceeds 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.

Comment thread tests/test_select.py
Comment thread tests/test_select.py Outdated
Comment thread tests/test_select.py Outdated
@Yann-CV
Yann-CV merged commit 9635a9b into goldener-data:main Sep 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a unit test for the usage of restrict_to and restriction_idx_key in select_in_dataset of GoldSelector

3 participants