Remove global random seed used for testing

未关闭
#1,060 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@SripriyaDevarapalli 已经在做这个了。

开始于 2026年10月12日。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
活跃
技术栈
numpy, python

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Python
星标
1.7k
派生
438
平均合并
53 分钟
30 天内合并 PR
2

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

quantumlib/OpenFermion 的其他 Issue

查看 quantumlib/OpenFermion 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。