GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #32123 from charris/backport-32062 · numpy/numpy@967688f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • numpy/random
    • mtrand.pyx
    • tests
      • test_randomstate.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎numpy/random/mtrand.pyx‎

Copy file name to clipboardExpand all lines: numpy/random/mtrand.pyx
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4833,7 +4833,7 @@ def seed(seed=None):
48334833
return _rand.seed(seed)
48344834
else:
48354835
bg_type = type(_rand._bit_generator)
4836-
_rand._bit_generator.state = bg_type(seed).state
4836+
_rand.set_state(bg_type(seed).state)
48374837

48384838
def get_bit_generator():
48394839
"""
Collapse file

‎numpy/random/tests/test_randomstate.py‎

Copy file name to clipboardExpand all lines: numpy/random/tests/test_randomstate.py
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,6 +2060,15 @@ def test_seed_alt_bit_gen(restore_singleton_bitgen):
20602060
assert state["state"]["inc"] != new_state["state"]["inc"]
20612061

20622062

2063+
@pytest.mark.thread_unsafe(reason="np.random.set_bit_generator affects global state")
2064+
def test_seed_alt_bit_gen_resets_gauss_cache(restore_singleton_bitgen):
2065+
np.random.set_bit_generator(PCG64(0))
2066+
np.random.seed(12345)
2067+
expected = np.random.standard_normal()
2068+
np.random.seed(12345)
2069+
assert np.random.standard_normal() == expected
2070+
2071+
20632072
@pytest.mark.thread_unsafe(reason="np.random.set_bit_generator affects global state")
20642073
def test_state_error_alt_bit_gen(restore_singleton_bitgen):
20652074
# GH 21808

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.