def ensure_float01(arr, dtype_preference='float32'):
 if (arr.dtype == 'uint8'):
  return (np.array(arr, dtype=dtype_preference) / 255)
 elif (arr.dtype in ('float32', 'float64')):
  return arr
 else:
  raise Exception(('ensure_float01 expects uint8 or float input but got %s with range [%g,%g,].' % (arr.dtype, arr.min(), arr.max())))

def ensure_float01 ( arr , dtype_preference = 'float32' ) : if ( arr . dtype == 'uint8' ) : return ( np . array ( arr , dtype = dtype_preference ) / 255 ) elif ( arr . dtype in ( 'float32' , 'float64' ) ) : return arr else : raise Exception ( ( 'ensure_float01 expects uint8 or float input but got %s with range [%g,%g,].' % ( arr . dtype , arr . min ( ) , arr . max ( ) ) ) )
if data is uint .