_ReaderBase.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:dataArtist 作者: radjkarl 项目源码 文件源码
def toFloat(self, arr, toFloat=True, forceFloat64=False):
        if hasattr(self, 'preferences'):
            p = self.preferences
            toFloat = p.pToFloat.value()
            forceFloat64 = p.pForceFloat64.value()

        if not toFloat:
            return arr
        arr = np.asanyarray(arr)
        try:
            if forceFloat64:
                dtype = np.float64
            else:
                dtype = {np.dtype('uint8'): np.float32,  # float16 is just to coarse and cause nans and infs
                         np.dtype('uint16'): np.float32,
                         np.dtype('uint32'): np.float64,
                         np.dtype('uint64'): np.float64}[arr.dtype]
            return arr.astype(dtype, copy=False)
        except KeyError:
            return arr
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号