File: 0009-Make-random-numbers-in-documentation-reproducible.patch

package info (click to toggle)
numpy 1%3A2.3.4%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 86,056 kB
  • sloc: python: 255,795; asm: 232,483; ansic: 212,593; cpp: 157,465; f90: 1,575; sh: 845; fortran: 567; makefile: 431; sed: 139; xml: 109; java: 97; perl: 82; cs: 62; javascript: 53; objc: 33; lex: 13; yacc: 9
file content (32 lines) | stat: -rw-r--r-- 1,209 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
From: =?utf-8?q?Timo_R=C3=B6hling?= <roehling@debian.org>
Date: Sat, 18 Oct 2025 10:52:50 +0200
Subject: Make random numbers in documentation reproducible

Forwarded: https://github.com/numpy/numpy/pull/30023
---
 doc/source/conf.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/doc/source/conf.py b/doc/source/conf.py
index 6d9ecd5..5634e60 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -628,3 +628,18 @@ try_examples_global_warning_text = (
     " report them on the"
     " [NumPy issue tracker](https://github.com/numpy/numpy/issues)."
 )
+
+
+# -----------------------------------------------------------------------------
+# Reproducible builds
+# -----------------------------------------------------------------------------
+
+# Seed the random number generators with a fixed value to make build results
+# reproducible. The actual seed does not matter as long as it is deterministic.
+
+# Seed legacy RNG
+numpy.random.seed(42)
+# Monkeypatch default_rng to return a deterministically seeded instance
+numpy.random.default_rng = \
+    lambda seed=None, actual_default_rng=numpy.random.default_rng: \
+        actual_default_rng(seed if seed is not None else 42)