1212from math import ceil
1313import os
1414import logging
15+ import warnings
1516
1617import numpy as np
1718
@@ -264,8 +265,8 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
264265 and magnified by the magnification factor.
265266
266267 `A` may be a greyscale image (MxN) with a dtype of `float32`,
267- `float64`, `uint16` or `uint8`, or an RGBA image (MxNx4) with
268- a dtype of `float32`, `float64`, or `uint8`.
268+ `float64`, `float128`, ` uint16` or `uint8`, or an RGBA image (MxNx4)
269+ with a dtype of `float32`, `float64`, `float128 `, or `uint8`.
269270
270271 If `unsampled` is True, the image will not be scaled, but an
271272 appropriate affine transformation will be returned instead.
@@ -361,6 +362,13 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
361362 a_min , a_max = np .int32 (0 ), np .int32 (1 )
362363 if inp_dtype .kind == 'f' :
363364 scaled_dtype = A .dtype
365+ # Cast to float64
366+ if A .dtype not in (np .float32 , np .float16 ):
367+ if A .dtype != np .float64 :
368+ warnings .warn (
369+ "Casting input data from '{0}' to 'float64'"
370+ "for imshow" .format (A .dtype ))
371+ scaled_dtype = np .float64
364372 else :
365373 # probably an integer of some type.
366374 da = a_max .astype (np .float64 ) - a_min .astype (np .float64 )
@@ -386,7 +394,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
386394 # of over numbers.
387395 if self .norm .vmin is not None and self .norm .vmax is not None :
388396 dv = (np .float64 (self .norm .vmax ) -
389- np .float64 (self .norm .vmin ))
397+ np .float64 (self .norm .vmin ))
390398 vmid = self .norm .vmin + dv / 2
391399 newmin = vmid - dv * 1.e7
392400 if newmin < a_min :
0 commit comments