(arr, dtype, msg="")
return arr
Force the dtype of a Numpy array.
Force the dtype of a Numpy array.
Force the dtype of a Numpy array .
def enforce_dtype(arr, dtype, msg=""):
    """Force the dtype of a Numpy array."""
    if isinstance(arr, np.ndarray):
        if arr.dtype is not np.dtype(dtype):
            log_debug("enforcing dtype for array %s %s" % (str(arr.dtype), msg))
            return np.array(arr, dtype)
    return arr
def enforce_dtype ( arr , dtype , msg = "" ) : if isinstance ( arr , np . ndarray ) : if arr . dtype is not np . dtype ( dtype ) : log_debug ( "enforcing dtype for array %s %s" % ( str ( arr . dtype ) , msg ) ) return np . array ( arr , dtype ) return arr