Skip to content

Commit 28bf5e6

Browse files
committed
Replace deprecated np.fromstring with np.frombuffer.
1 parent 5cb501c commit 28bf5e6

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

lib/matplotlib/backends/backend_agg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def post_processing(image, dpi):
356356
self._update_methods()
357357

358358
if w > 0 and h > 0:
359-
img = np.fromstring(buffer, np.uint8)
359+
img = np.frombuffer(buffer, np.uint8)
360360
img, ox, oy = post_processing(img.reshape((h, w, 4)) / 255.,
361361
self.dpi)
362362
gc = self.new_gc()

lib/matplotlib/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,9 +1460,9 @@ def pil_to_array(pilImage):
14601460
# return MxN luminance array of uint16
14611461
raw = pilImage.tobytes('raw', pilImage.mode)
14621462
if pilImage.mode.endswith('B'):
1463-
x = np.fromstring(raw, '>u2')
1463+
x = np.frombuffer(raw, '>u2')
14641464
else:
1465-
x = np.fromstring(raw, '<u2')
1465+
x = np.frombuffer(raw, '<u2')
14661466
return x.reshape(pilImage.size[::-1]).astype('=u2')
14671467
else: # try to convert to an rgba image
14681468
try:

lib/matplotlib/tests/test_mathtext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def test_single_minus_sign():
267267

268268
buff = io.BytesIO()
269269
plt.savefig(buff, format="rgba", dpi=1000)
270-
array = np.fromstring(buff.getvalue(), dtype=np.uint8)
270+
array = np.frombuffer(buff.getvalue(), dtype=np.uint8)
271271

272272
# If this fails, it would be all white
273273
assert not np.all(array == 0xff)

lib/matplotlib/tests/test_simplification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def test_start_with_moveto():
264264
AABHqP//ej8AAD6z//+FPwAANb7//48/AAAsyf//lz8AACPU//+ePwAAGt///6M/AAAR6v//pj8A
265265
AAj1//+nPwAA/////w=="""
266266

267-
verts = np.fromstring(base64.decodebytes(data), dtype='<i4')
267+
verts = np.frombuffer(base64.decodebytes(data), dtype='<i4')
268268
verts = verts.reshape((len(verts) // 2, 2))
269269
path = Path(verts)
270270
segs = path.iter_segments(transforms.IdentityTransform(),

0 commit comments

Comments
 (0)