python类IOError()的实例源码

test_multiarray.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_nofile(self):
        # this should probably be supported as a file
        # but for now test for proper errors
        b = io.BytesIO()
        assert_raises(IOError, np.fromfile, b, np.uint8, 80)
        d = np.ones(7);
        assert_raises(IOError, lambda x: x.tofile(b), d)
test_multiarray.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 42 收藏 0 点赞 0 评论 0
def test_unbuffered_fromfile(self):
        # gh-6246
        self.x.tofile(self.filename)

        def fail(*args, **kwargs):
            raise io.IOError('Can not tell or seek')

        f = io.open(self.filename, 'rb', buffering=0)
        f.seek = fail
        f.tell = fail
        y = np.fromfile(self.filename, dtype=self.dtype)
        assert_array_equal(y, self.x.flat)
test_multiarray.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_nofile(self):
        # this should probably be supported as a file
        # but for now test for proper errors
        b = io.BytesIO()
        assert_raises(IOError, np.fromfile, b, np.uint8, 80)
        d = np.ones(7);
        assert_raises(IOError, lambda x: x.tofile(b), d)
test_multiarray.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def test_unbuffered_fromfile(self):
        # gh-6246
        self.x.tofile(self.filename)

        def fail(*args, **kwargs):
            raise io.IOError('Can not tell or seek')

        f = io.open(self.filename, 'rb', buffering=0)
        f.seek = fail
        f.tell = fail
        y = np.fromfile(self.filename, dtype=self.dtype)
        assert_array_equal(y, self.x.flat)
test_multiarray.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_nofile(self):
        # this should probably be supported as a file
        # but for now test for proper errors
        b = io.BytesIO()
        assert_raises(IOError, np.fromfile, b, np.uint8, 80)
        d = np.ones(7);
        assert_raises(IOError, lambda x: x.tofile(b), d)
test_multiarray.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_unbuffered_fromfile(self):
        # gh-6246
        self.x.tofile(self.filename)

        def fail(*args, **kwargs):
            raise io.IOError('Can not tell or seek')

        f = io.open(self.filename, 'rb', buffering=0)
        f.seek = fail
        f.tell = fail
        y = np.fromfile(self.filename, dtype=self.dtype)
        assert_array_equal(y, self.x.flat)
test_multiarray.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_nofile(self):
        # this should probably be supported as a file
        # but for now test for proper errors
        b = io.BytesIO()
        assert_raises(IOError, np.fromfile, b, np.uint8, 80)
        d = np.ones(7)
        assert_raises(IOError, lambda x: x.tofile(b), d)
test_multiarray.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_unbuffered_fromfile(self):
        # gh-6246
        self.x.tofile(self.filename)

        def fail(*args, **kwargs):
            raise io.IOError('Can not tell or seek')

        with io.open(self.filename, 'rb', buffering=0) as f:
            f.seek = fail
            f.tell = fail
            y = np.fromfile(self.filename, dtype=self.dtype)
            assert_array_equal(y, self.x.flat)
test_multiarray.py 文件源码 项目:Alfred 作者: jkachhadia 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_nofile(self):
        # this should probably be supported as a file
        # but for now test for proper errors
        b = io.BytesIO()
        assert_raises(IOError, np.fromfile, b, np.uint8, 80)
        d = np.ones(7);
        assert_raises(IOError, lambda x: x.tofile(b), d)
test_multiarray.py 文件源码 项目:Alfred 作者: jkachhadia 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_unbuffered_fromfile(self):
        # gh-6246
        self.x.tofile(self.filename)

        def fail(*args, **kwargs):
            raise io.IOError('Can not tell or seek')

        f = io.open(self.filename, 'rb', buffering=0)
        f.seek = fail
        f.tell = fail
        y = np.fromfile(self.filename, dtype=self.dtype)
        assert_array_equal(y, self.x.flat)


问题


面经


文章

微信
公众号

扫码关注公众号