Skip to content

Commit 2ea15da

Browse files
committed
Py3fy webagg/nbagg.
(The locking of RendererAgg is already done by the super class, and thus redundant here.)
1 parent 53305a4 commit 2ea15da

File tree

3 files changed

+6
-25
lines changed

3 files changed

+6
-25
lines changed

lib/matplotlib/backends/backend_nbagg.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# lib/matplotlib/backends/web_backend/nbagg_uat.ipynb to help verify
44
# that changes made maintain expected behaviour.
55

6-
import six
7-
86
from base64 import b64encode
97
import io
108
import json
@@ -204,9 +202,7 @@ def send_json(self, content):
204202
def send_binary(self, blob):
205203
# The comm is ascii, so we always send the image in base64
206204
# encoded data URL form.
207-
data = b64encode(blob)
208-
if six.PY3:
209-
data = data.decode('ascii')
205+
data = b64encode(blob).decode('ascii')
210206
data_uri = "data:image/png;base64,{0}".format(data)
211207
self.comm.send({'data': data_uri})
212208

lib/matplotlib/backends/backend_webagg.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
"""
22
Displays Agg images in the browser, with interactivity
33
"""
4-
from __future__ import (absolute_import, division, print_function,
5-
unicode_literals)
64

75
# The WebAgg backend is divided into two modules:
86
#
@@ -13,10 +11,9 @@
1311
# - `backend_webagg.py` contains a concrete implementation of a basic
1412
# application, implemented with tornado.
1513

16-
import six
17-
1814
from contextlib import contextmanager
1915
import errno
16+
from io import BytesIO
2017
import json
2118
import os
2219
import random
@@ -135,7 +132,7 @@ def get(self, fignum, fmt):
135132

136133
self.set_header('Content-Type', mimetypes.get(fmt, 'binary'))
137134

138-
buff = six.BytesIO()
135+
buff = BytesIO()
139136
manager.canvas.figure.savefig(buff, format=fmt)
140137
self.write(buff.getvalue())
141138

lib/matplotlib/backends/backend_webagg_core.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
# - `backend_webagg.py` contains a concrete implementation of a basic
1111
# application, implemented with tornado.
1212

13-
from __future__ import (absolute_import, division, print_function,
14-
unicode_literals)
15-
16-
import six
17-
1813
import datetime
1914
import io
2015
import json
@@ -26,8 +21,7 @@
2621

2722
from matplotlib.backends import backend_agg
2823
from matplotlib.backend_bases import _Backend
29-
from matplotlib import backend_bases
30-
from matplotlib import _png
24+
from matplotlib import backend_bases, _png
3125

3226

3327
# http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
@@ -150,17 +144,11 @@ def show(self):
150144
show()
151145

152146
def draw(self):
153-
renderer = self.get_renderer(cleared=True)
154-
155147
self._png_is_old = True
156-
157-
backend_agg.RendererAgg.lock.acquire()
158148
try:
159-
self.figure.draw(renderer)
149+
super().draw()
160150
finally:
161-
backend_agg.RendererAgg.lock.release()
162-
# Swap the frames
163-
self.manager.refresh_all()
151+
self.manager.refresh_all() # Swap the frames.
164152

165153
def draw_idle(self):
166154
self.send_event("draw")

0 commit comments

Comments
 (0)