FIX Fixes deprecation of tostring on numpy master
@@ -369,23 +369,23 @@ def toimage(arr, high=255, low=0, cmin=None, cmax=None, pal=None,
shape = (shape[1], shape[0]) # columns show up first
if mode == 'F':
data32 = data.astype(numpy.float32)
- image = Image.frombytes(mode, shape, data32.tostring())
+ image = Image.frombytes(mode, shape, data32.tobytes())
return image
if mode in [None, 'L', 'P']:
bytedata = bytescale(data, high=high, low=low,
cmin=cmin, cmax=cmax)
- image = Image.frombytes('L', shape, bytedata.tostring())
+ image = Image.frombytes('L', shape, bytedata.tobytes())
if pal is not None:
- image.putpalette(asarray(pal, dtype=uint8).tostring())
+ image.putpalette(asarray(pal, dtype=uint8).tobytes())
# Becomes a mode='P' automagically.
elif mode == 'P': # default gray-scale
pal = (arange(0, 256, 1, dtype=uint8)[:, newaxis] *
ones((3,), dtype=uint8)[newaxis, :])
- image.putpalette(asarray(pal, dtype=uint8).tostring())
+ image.putpalette(asarray(pal, dtype=uint8).tobytes())
return image
if mode == '1': # high input gives threshold for 1
bytedata = (data > high)
- image = Image.frombytes('1', shape, bytedata.tostring())
+ image = Image.frombytes('1', shape, bytedata.tobytes())
return image
if cmin is None:
cmin = amin(ravel(data))
@@ -394,7 +394,7 @@ def toimage(arr, high=255, low=0, cmin=None, cmax=None, pal=None,
data = (data*1.0 - cmin)*(high - low)/(cmax - cmin) + low
if mode == 'I':
data32 = data.astype(numpy.uint32)
- image = Image.frombytes(mode, shape, data32.tostring())
+ image = Image.frombytes(mode, shape, data32.tobytes())
else:
raise ValueError(_errstr)
return image
@@ -419,13 +419,13 @@ def toimage(arr, high=255, low=0, cmin=None, cmax=None, pal=None,
bytedata = bytescale(data, high=high, low=low, cmin=cmin, cmax=cmax)
if ca == 2:
- strdata = bytedata.tostring()
+ strdata = bytedata.tobytes()
shape = (shape[1], shape[0])
elif ca == 1:
- strdata = transpose(bytedata, (0, 2, 1)).tostring()
+ strdata = transpose(bytedata, (0, 2, 1)).tobytes()
shape = (shape[2], shape[0])
elif ca == 0:
- strdata = transpose(bytedata, (1, 2, 0)).tostring()
+ strdata = transpose(bytedata, (1, 2, 0)).tobytes()
shape = (shape[2], shape[1])
if mode is None:
if numch == 3:
