FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Backport PR #24785 on branch v3.6.2-doc (Fix random generation of single floats) by meeseeksmachine · Pull Request #24792 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion examples/animation/bayes_update.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __call__(self, i):
return self.line,

# Choose success based on exceed a threshold with a uniform pick
if np.random.rand(1,) < self.prob:
if np.random.rand() < self.prob:
self.success += 1
y = beta_pdf(self.x, self.success + 1, (i - self.success) + 1)
self.line.set_data(self.x, y)
Expand Down
6 changes: 3 additions & 3 deletions examples/animation/strip_chart.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ def update(self, y):
t = self.tdata[0] + len(self.tdata) * self.dt

self.tdata.append(t)
self.ydata.append(float(y))
self.ydata.append(y)
self.line.set_data(self.tdata, self.ydata)
return self.line,


def emitter(p=0.1):
"""Return a random value in [0, 1) with probability p, else 0."""
while True:
v = np.random.rand(1)
v = np.random.rand()
if v > p:
yield 0.
else:
yield np.random.rand(1)
yield np.random.rand()


# Fixing random state for reproducibility
Expand Down

Back | FazBrowse Home | New Git URL