ENH: Bool dtype conversion speed improvements.

This commit is contained in:
Stefan van der Walt
2012-09-10 22:47:10 -07:00
parent ef06d4e474
commit 56b4ba67e6
+6 -3
View File
@@ -155,11 +155,14 @@ def convert(image, dtype, force_copy=False, uniform=False):
if kind_in in "fi":
sign_loss()
prec_loss()
return dtype(image)
return image > dtype_in(0)
if kind_in == 'b':
# from binary image, to float and to integer
return dtype(image) * dtype(dtype_range[dtype][1])
result = dtype(image)
if kind != 'f':
result *= dtype(dtype_range[dtype][1])
return result
if kind in 'ui':
imin = np.iinfo(dtype).min