Add tests for the _validate validation utilities#286
Open
r1cksync wants to merge 1 commit into
Open
Conversation
jax_privacy/_validate.py centralizes the input validation used across the public API (accounting, batch_selection, ...), but had no dedicated test coverage. Add tests/_validate_test.py covering all seven helpers -- non_negative, positive, in_range, equal, batch, strategy, and multi_owner -- including valid inputs, every rejection path, multi-keyword validation, and edge cases (empty/None pytrees, non-array and scalar leaves, inconsistent batch dimensions, and duplicate multi-owner pairs).
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.
What
Adds
tests/_validate_test.py, covering the centralized validation utilities injax_privacy/_validate.py._validate.pyis load-bearing — its helpers guard the public API surface (e.g.accounting's event builders,batch_selection's sampling strategies) and turn invalid inputs into clear, consistentValueErrors — but it had no dedicated test file.Coverage
49 tests across all seven helpers:
non_negative/positive— accept valid values, reject the boundary/negative cases, validate every keyword, no-op on no args.in_range— inclusive endpoints, out-of-range rejection, multi-keyword.equal— equal/unequal, multi-keyword.batch— returns the shared batch size; rejects empty/Nonepytrees, non-array leaves, scalar (0-d) leaves, and inconsistent first-axis sizes.strategy— accepts 1-D arrays/lists withinmax_size; rejects non-1-D, empty, and oversized.multi_owner— accepts valid edge lists (incl. repeated ids in distinct pairs); rejects non-1-D, length mismatch, empty graphs, and duplicate(example, user)pairs.Testing
Tests-only; no library code changes.