From 93d45ecc540047f026f53cfbd494639851f0dc01 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Mon, 30 Mar 2020 12:16:05 +0100 Subject: [PATCH] MAINT: Replace uses of tostring with tobytes tostring() is the pre-numpy-1.9 name, and is not a good name in python3 where the return type is _not_ `str`. --- lib/matplotlib/backends/backend_pdf.py | 4 ++-- lib/matplotlib/backends/backend_ps.py | 2 +- lib/matplotlib/backends/backend_wx.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/backends/backend_pdf.py b/lib/matplotlib/backends/backend_pdf.py index 1399e8a52fc5..32645ff92a5f 100644 --- a/lib/matplotlib/backends/backend_pdf.py +++ b/lib/matplotlib/backends/backend_pdf.py @@ -1406,7 +1406,7 @@ def writeGouraudTriangles(self): streamarr['points'] = (flat_points - points_min) * factor streamarr['colors'] = flat_colors[:, :colordim] * 255.0 - self.write(streamarr.tostring()) + self.write(streamarr.tobytes()) self.endStream() self.writeObject(self.gouraudObject, gouraudDict) @@ -1497,7 +1497,7 @@ def _writeImg(self, data, id, smask=None): if png: self._writePng(data) else: - self.currentstream.write(data.tostring()) + self.currentstream.write(data.tobytes()) self.endStream() def writeImages(self): diff --git a/lib/matplotlib/backends/backend_ps.py b/lib/matplotlib/backends/backend_ps.py index acf3f03747ea..d95d6ea60f2b 100644 --- a/lib/matplotlib/backends/backend_ps.py +++ b/lib/matplotlib/backends/backend_ps.py @@ -632,7 +632,7 @@ def draw_gouraud_triangles(self, gc, points, colors, trans): streamarr['flags'] = 0 streamarr['points'] = (flat_points - points_min) * factor streamarr['colors'] = flat_colors[:, :3] * 255.0 - stream = quote_ps_string(streamarr.tostring()) + stream = quote_ps_string(streamarr.tobytes()) self._pswriter.write(f"""\ gsave diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index 9d4b773e7f2a..63c02979a6e8 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -237,7 +237,7 @@ def draw_image(self, gc, x, y, im): w = self.width h = self.height rows, cols = im.shape[:2] - bitmap = wx.Bitmap.FromBufferRGBA(cols, rows, im.tostring()) + bitmap = wx.Bitmap.FromBufferRGBA(cols, rows, im.tobytes()) gc.select() gc.gfx_ctx.DrawBitmap(bitmap, int(l), int(self.height - b), int(w), int(-h))