Skip to content

Add unit test for QSimSimulator.get_seed#1027

Open
mhucka wants to merge 2 commits intoquantumlib:mainfrom
mhucka:testing-improvement-get-seed-16179423082655356207
Open

Add unit test for QSimSimulator.get_seed#1027
mhucka wants to merge 2 commits intoquantumlib:mainfrom
mhucka:testing-improvement-get-seed-16179423082655356207

Conversation

@mhucka
Copy link
Copy Markdown
Collaborator

@mhucka mhucka commented Mar 26, 2026

Added a new test case test_get_seed to qsimcirq_tests/qsimcirq_test.py to verify:

  • The returned seed is within the expected [0, 2^31 - 1) range.
  • The simulator is deterministic when initialized with a fixed seed.
  • Subsequent calls to get_seed return different values.

Added a new test case `test_get_seed` to `qsimcirq_tests/qsimcirq_test.py` to verify:
- The returned seed is within the expected [0, 2^31 - 1) range.
- The simulator is deterministic when initialized with a fixed seed.
- Subsequent calls to `get_seed` return different values.
@github-actions github-actions bot added the size: S 10< lines changed <50 label Mar 26, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new test, test_get_seed, in qsimcirq_test.py to validate the QSimSimulator.get_seed() method. The test covers the seed's value range, determinism when initialized with the same seed, and the expectation that subsequent calls to get_seed() yield different values. A potential flakiness issue was noted in the test for subsequent calls, as asserting sim.get_seed() != sim.get_seed() relies on a statistical unlikelihood rather than a guarantee, suggesting a more robust approach of generating multiple seeds and asserting their diversity.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S 10< lines changed <50

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant