def test_read_write_sparse_matrix_csc_compressed(tmpdir): expected = sp.csc_matrix( (np.array([1, 2, 3, 4, 5, 6]), (np.array([0, 0, 1, 2, 2, 2]), np.array([0, 2, 2, 0, 1, 2]))), shape=(3, 3)) filename = str(tmpdir.join('test_read_write_sparse_matrix_csc_compressed.npz')) io.write_sparse_matrix(expected, filename, compressed=True) observed = io.read_sparse_matrix(filename, kind='csc') assert abs(observed - expected).nnz == 0
def test_read_write_sparse_csc(self, tmpdir): expected = sp.csc_matrix( ( np.array([1, 2, 3, 4, 5, 6]), (np.array([0, 0, 1, 2, 2, 2]), np.array([0, 2, 2, 0, 1, 2])), ), shape=(3, 3), ) filepath = str(tmpdir.join("test_read_write_sparse_matrix_csc.npz")) io.write_sparse_matrix(expected, filepath, compressed=False) observed = io.read_sparse_matrix(filepath, kind="csc") assert abs(observed - expected).nnz == 0