Skip to content

Commit cf4f8e1

Browse files
authored
Merge pull request #19117 from QuLogic/rename-var
Rename a confusing variable.
2 parents b556e62 + 4c5da38 commit cf4f8e1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/matplotlib/backends/backend_webagg_core.py

+6-5
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)