Skip to content

Commit 8099a27

Browse files
tacaswellmeeseeksmachine
authored andcommitted
Backport PR #24785: Fix random generation of single floats
1 parent 4ba0a19 commit 8099a27

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

examples/animation/bayes_update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __call__(self, i):
4747
return self.line,
4848

4949
# Choose success based on exceed a threshold with a uniform pick
50-
if np.random.rand(1,) < self.prob:
50+
if np.random.rand() < self.prob:
5151
self.success += 1
5252
y = beta_pdf(self.x, self.success + 1, (i - self.success) + 1)
5353
self.line.set_data(self.x, y)

examples/animation/strip_chart.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ def update(self, y):
3737
t = self.tdata[0] + len(self.tdata) * self.dt
3838

3939
self.tdata.append(t)
40-
self.ydata.append(float(y))
40+
self.ydata.append(y)
4141
self.line.set_data(self.tdata, self.ydata)
4242
return self.line,
4343

4444

4545
def emitter(p=0.1):
4646
"""Return a random value in [0, 1) with probability p, else 0."""
4747
while True:
48-
v = np.random.rand(1)
48+
v = np.random.rand()
4949
if v > p:
5050
yield 0.
5151
else:
52-
yield np.random.rand(1)
52+
yield np.random.rand()
5353

5454

5555
# Fixing random state for reproducibility

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy