Remove global random seed used for testing

Aperta
#1,060 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@SripriyaDevarapalli ci sta già lavorando.

Dal 12/10/2026.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
numpy, python

Direzione di ricerca

Start by reading the pytest configuration changed in PR #1056 and locate tests that rely on random numbers in their scenarios. Review how those tests seed and use randomness, then identify which need independent generators passed explicitly. Done means the global seed is removed and affected tests retain reliable, independent random state.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

a: performance a: python e: experienced no QC knowledge needed

PR #1056 modified the pytest configuration to set a global random number seed, to deal with flaky tests that failed sporadically because some numerical comparisons exceeded tolerances undpredictably. Setting a global seed is not good practice. The seeds for test scenarios should be revised:

  • Avoid global seeds. It's generally better to avoid setting a global seed for all tests. Global seeds can cause unexpected behavior when different parts of the code rely on random numbers.

  • Use numpy.random.default_rng. It's considered better to create a Generator instance with a seed at the beginning of each test or test suite. This ensures that each test has its own independent random state.

  • Pass Generator objects. Pass the Generator object around as an argument. This makes the random number generation explicit and avoids relying on global state.

Lingua principale
Python
Stelle
1.7k
Fork
438
Merge medio
53m
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di quantumlib/OpenFermion

Tutte le issue di quantumlib/OpenFermion

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.