Skip to content

Add tests for the _validate validation utilities#286

Open
r1cksync wants to merge 1 commit into
google-deepmind:mainfrom
r1cksync:add-validate-tests
Open

Add tests for the _validate validation utilities#286
r1cksync wants to merge 1 commit into
google-deepmind:mainfrom
r1cksync:add-validate-tests

Conversation

@r1cksync

Copy link
Copy Markdown
Contributor

What

Adds tests/_validate_test.py, covering the centralized validation utilities in jax_privacy/_validate.py.

_validate.py is 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, consistent ValueErrors — 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/None pytrees, non-array leaves, scalar (0-d) leaves, and inconsistent first-axis sizes.
  • strategy — accepts 1-D arrays/lists within max_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

python -m pytest tests/_validate_test.py   # 49 passed

Tests-only; no library code changes.

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).
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.

1 participant