Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4c5da38

Browse filesBrowse files
committed
Rename a confusing variable.
As noted in #19059, there is both a `buff` and `buf` in this function. The latter is a PNG file, so rename it to `png`.
1 parent b556e62 commit 4c5da38
Copy full SHA for 4c5da38

File tree

Expand file treeCollapse file tree

1 file changed

+6
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-5
lines changed

‎lib/matplotlib/backends/backend_webagg_core.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_webagg_core.py
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,15 @@ def get_diff_image(self):
196196
diff = buff != self._last_buff
197197
output = np.where(diff, buff, 0)
198198

199-
buf = BytesIO()
200-
data = output.view(dtype=np.uint8).reshape((*output.shape, 4))
201-
Image.fromarray(data).save(buf, format="png")
202-
# store the current buffer so we can compute the next diff
199+
# Store the current buffer so we can compute the next diff.
203200
np.copyto(self._last_buff, buff)
204201
self._force_full = False
205202
self._png_is_old = False
206-
return buf.getvalue()
203+
204+
data = output.view(dtype=np.uint8).reshape((*output.shape, 4))
205+
with BytesIO() as png:
206+
Image.fromarray(data).save(png, format="png")
207+
return png.getvalue()
207208

208209
def get_renderer(self, cleared=None):
209210
# Mirrors super.get_renderer, but caches the old one so that we can do

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.