Skip to content

Commit 7c4f28c

Browse files
QuLogicArchangeGabriel
authored andcommitted
Replace deprecated np.fromstring with np.frombuffer.
1 parent 3f4d8e9 commit 7c4f28c

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
@@ -391,7 +391,7 @@ def post_processing(image, dpi):
391391
self._update_methods()
392392

393393
if w > 0 and h > 0:
394-
img = np.fromstring(buffer, np.uint8)
394+
img = np.frombuffer(buffer, np.uint8)
395395
img, ox, oy = post_processing(img.reshape((h, w, 4)) / 255.,
396396
self.dpi)
397397
gc = self.new_gc()

lib/matplotlib/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,9 +1447,9 @@ def pil_to_array(pilImage):
14471447
# return MxN luminance array of uint16
14481448
raw = pilImage.tobytes('raw', pilImage.mode)
14491449
if pilImage.mode.endswith('B'):
1450-
x = np.fromstring(raw, '>u2')
1450+
x = np.frombuffer(raw, '>u2')
14511451
else:
1452-
x = np.fromstring(raw, '<u2')
1452+
x = np.frombuffer(raw, '<u2')
14531453
return x.reshape(pilImage.size[::-1]).astype('=u2')
14541454
else: # try to convert to an rgba image
14551455
try:

lib/matplotlib/tests/test_mathtext.py

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

272272
buff = io.BytesIO()
273273
plt.savefig(buff, format="rgba", dpi=1000)
274-
array = np.fromstring(buff.getvalue(), dtype=np.uint8)
274+
array = np.frombuffer(buff.getvalue(), dtype=np.uint8)
275275

276276
# If this fails, it would be all white
277277
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
@@ -273,7 +273,7 @@ def test_start_with_moveto():
273273
# Python 2 case
274274
decodebytes = base64.decodestring
275275

276-
verts = np.fromstring(decodebytes(data), dtype='<i4')
276+
verts = np.frombuffer(decodebytes(data), dtype='<i4')
277277
verts = verts.reshape((len(verts) // 2, 2))
278278
path = Path(verts)
279279
segs = path.iter_segments(transforms.IdentityTransform(),

0 commit comments

Comments
 (0)