Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 93d45ec

Browse files
committed
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`.
1 parent 04a3155 commit 93d45ec

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ def writeGouraudTriangles(self):
14061406
streamarr['points'] = (flat_points - points_min) * factor
14071407
streamarr['colors'] = flat_colors[:, :colordim] * 255.0
14081408

1409-
self.write(streamarr.tostring())
1409+
self.write(streamarr.tobytes())
14101410
self.endStream()
14111411
self.writeObject(self.gouraudObject, gouraudDict)
14121412

@@ -1497,7 +1497,7 @@ def _writeImg(self, data, id, smask=None):
14971497
if png:
14981498
self._writePng(data)
14991499
else:
1500-
self.currentstream.write(data.tostring())
1500+
self.currentstream.write(data.tobytes())
15011501
self.endStream()
15021502

15031503
def writeImages(self):

lib/matplotlib/backends/backend_ps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ def draw_gouraud_triangles(self, gc, points, colors, trans):
632632
streamarr['flags'] = 0
633633
streamarr['points'] = (flat_points - points_min) * factor
634634
streamarr['colors'] = flat_colors[:, :3] * 255.0
635-
stream = quote_ps_string(streamarr.tostring())
635+
stream = quote_ps_string(streamarr.tobytes())
636636

637637
self._pswriter.write(f"""\
638638
gsave

lib/matplotlib/backends/backend_wx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def draw_image(self, gc, x, y, im):
237237
w = self.width
238238
h = self.height
239239
rows, cols = im.shape[:2]
240-
bitmap = wx.Bitmap.FromBufferRGBA(cols, rows, im.tostring())
240+
bitmap = wx.Bitmap.FromBufferRGBA(cols, rows, im.tobytes())
241241
gc.select()
242242
gc.gfx_ctx.DrawBitmap(bitmap, int(l), int(self.height - b),
243243
int(w), int(-h))

0 commit comments

Comments
 (0)