test_io.py 文件源码

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

项目:radar 作者: amoose136 项目源码 文件源码
def test_from_float_hex(self):
        # IEEE doubles and floats only, otherwise the float32
        # conversion may fail.
        tgt = np.logspace(-10, 10, 5).astype(np.float32)
        tgt = np.hstack((tgt, -tgt)).astype(np.float)
        inp = '\n'.join(map(float.hex, tgt))
        c = TextIO()
        c.write(inp)
        for dt in [np.float, np.float32]:
            c.seek(0)
            res = np.loadtxt(c, dtype=dt)
            assert_equal(res, tgt, err_msg="%s" % dt)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号