Conversation
Following best practices mentioned in issue quantumlib#1060, the global `np.random.seed` and `random.seed` calls from the conftest.py `set_random_seed` fixture have been completely removed. To fix the resulting pytest-xdist "Different tests were collected" errors arising from dynamically random generated lists passed to `@pytest.mark.parametrize`, those test generation logics have been updated to either use locally scoped seeds, explicitly predefined test sets, or fixed inputs.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where tests relied on global random seeds and dynamically generated parameters, leading to potential non-reproducibility. By removing the global seed and replacing random parameter generation with fixed values or localized seeding, the changes ensure that tests are deterministic and consistently verifiable. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request commendably removes the global random seed from conftest.py to improve test reproducibility, replacing random parameter generation with deterministic, hardcoded values across several test files. The changes are mostly correct and follow good testing practices. However, I've identified one instance where a for loop was inadvertently left in place after hardcoding values, leading to redundant test executions. My specific comment provides details on how to address this.
| [ | ||
| ( | ||
| (np.random.uniform(-5, 5) + 1j * np.random.uniform(-5, 5), np.random.uniform(-5, 5)), | ||
| np.random.uniform(-5, 5), | ||
| (1.2 + 3.4j, 2.1), | ||
| -1.5, | ||
| ) | ||
| for _ in range(5) | ||
| ], |
There was a problem hiding this comment.
The list comprehension with for _ in range(5) on line 269, combined with the now hard-coded values, will cause the test test_quadratic_fermionic_simulation_gate_unitary to run 5 times with the exact same parameters. This is redundant and inefficient. You should either provide different sets of hard-coded parameters for each run (as you've done elsewhere in this file) or remove the loop to run the test just once.
[
((1.2 + 3.4j, 2.1), -1.5)
],
Removed the global seed from conftest and fixed the randomly parametrized inputs.
PR created automatically by Jules for task 6998816404824291497 started by @mhucka