示例#1
0
    def test_loadmat(self):
        # Save data with string path, load with pathlib.Path
        with tempdir() as temp_dir:
            path = Path(temp_dir) / 'data.mat'
            scipy.io.savemat(str(path), {'data': self.data})

            mat_contents = scipy.io.loadmat(path)
            assert_((mat_contents['data'] == self.data).all())
示例#2
0
    def test_whosmat(self):
        # Save data with string path, load with pathlib.Path
        with tempdir() as temp_dir:
            path = Path(temp_dir) / 'data.mat'
            scipy.io.savemat(str(path), {'data': self.data})

            contents = scipy.io.whosmat(path)
            assert_(contents[0] == ('data', (1, 5), 'int64'))
    def test_wavfile_write(self):
        # Read from str path, write to Path
        input_path = Path(__file__).parent / 'data/test-8000Hz-le-2ch-1byteu.wav'
        rate, data = scipy.io.wavfile.read(str(input_path))

        with tempdir() as temp_dir:
            output_path = Path(temp_dir) / input_path.name
            scipy.io.wavfile.write(output_path, rate, data)
示例#4
0
    def test_wavfile_write(self):
        # Read from str path, write to Path
        input_path = Path(__file__).parent / 'data/test-8000Hz-le-2ch-1byteu.wav'
        rate, data = scipy.io.wavfile.read(str(input_path))

        with tempdir() as temp_dir:
            output_path = Path(temp_dir) / input_path.name
            scipy.io.wavfile.write(output_path, rate, data)
示例#5
0
    def test_whosmat(self):
        # Save data with string path, load with pathlib.Path
        with tempdir() as temp_dir:
            path = Path(temp_dir) / 'data.mat'
            scipy.io.savemat(str(path), {'data': self.data})

            contents = scipy.io.whosmat(path)
            assert_(contents[0] == ('data', (1, 5), 'int64'))
示例#6
0
    def test_loadmat(self):
        # Save data with string path, load with pathlib.Path
        with tempdir() as temp_dir:
            path = Path(temp_dir) / 'data.mat'
            scipy.io.savemat(str(path), {'data': self.data})

            mat_contents = scipy.io.loadmat(path)
            assert_((mat_contents['data'] == self.data).all())
示例#7
0
    def test_hb_read(self):
        # Save data with string path, load with pathlib.Path
        with tempdir() as temp_dir:
            data = scipy.sparse.csr_matrix(scipy.sparse.eye(3))
            path = Path(temp_dir) / 'data.hb'
            scipy.io.harwell_boeing.hb_write(str(path), data)

            data_new = scipy.io.harwell_boeing.hb_read(path)
            assert_((data_new != data).nnz == 0)
示例#8
0
    def test_mmio_read(self):
        # Save data with string path, load with pathlib.Path
        with tempdir() as temp_dir:
            data = scipy.sparse.csr_matrix(scipy.sparse.eye(3))
            path = Path(temp_dir) / 'data.mtx'
            scipy.io.mmwrite(str(path), data)

            data_new = scipy.io.mmread(path)
            assert (data_new != data).nnz == 0
示例#9
0
    def test_hb_read(self):
        # Save data with string path, load with pathlib.Path
        with tempdir() as temp_dir:
            data = scipy.sparse.csr_matrix(scipy.sparse.eye(3))
            path = Path(temp_dir) / 'data.hb'
            scipy.io.harwell_boeing.hb_write(str(path), data)

            data_new = scipy.io.harwell_boeing.hb_read(path)
            assert_((data_new != data).nnz == 0)
示例#10
0
def test_tempdir():
    with tempdir() as tmpdir:
        fname = pjoin(tmpdir, 'example_file.txt')
        with open(fname, 'wt') as fobj:
            fobj.write('a string\\n')
    assert_(not exists(tmpdir))
示例#11
0
 def test_hb_write(self):
     with tempdir() as temp_dir:
         data = scipy.sparse.csr_matrix(scipy.sparse.eye(3))
         path = Path(temp_dir) / 'data.hb'
         scipy.io.harwell_boeing.hb_write(path, data)
         assert_(path.is_file())
示例#12
0
 def test_savemat(self):
     with tempdir() as temp_dir:
         path = Path(temp_dir) / 'data.mat'
         scipy.io.savemat(path, {'data': self.data})
         assert_(path.is_file())
示例#13
0
 def test_mmio_write(self):
     with tempdir() as temp_dir:
         data = scipy.sparse.csr_matrix(scipy.sparse.eye(3))
         path = Path(temp_dir) / 'data.mtx'
         scipy.io.mmwrite(path, data)
示例#14
0
def test_tempdir():
    with tempdir() as tmpdir:
        fname = pjoin(tmpdir, 'example_file.txt')
        with open(fname, 'wt') as fobj:
            fobj.write('a string\\n')
    assert_(not exists(tmpdir))
示例#15
0
 def test_hb_write(self):
     with tempdir() as temp_dir:
         data = scipy.sparse.csr_matrix(scipy.sparse.eye(3))
         path = Path(temp_dir) / 'data.hb'
         scipy.io.harwell_boeing.hb_write(path, data)
         assert_(path.is_file())
示例#16
0
 def test_savemat(self):
     with tempdir() as temp_dir:
         path = Path(temp_dir) / 'data.mat'
         scipy.io.savemat(path, {'data': self.data})
         assert_(path.is_file())