Skip to content

Commit

Permalink
simplify create empty sparse matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
rm1113 committed Sep 17, 2024
1 parent 1ac47d4 commit 12cde3e
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions cap_anndata/cap_anndata.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,7 @@ def create_layer(self,
matrix_shape = (0, 0)
sparse_class = ss.csr_matrix if format == "csr" else ss.csc_matrix
data = sparse_class(matrix_shape, dtype=data_dtype)
group = self._file.create_group(dest)
# https://anndata.readthedocs.io/en/latest/fileformat-prose.html#sparse-arrays
group.attrs['encoding-type'] = f'{format}_matrix'
group.attrs['encoding-version'] = '0.1.0'
group.attrs['shape'] = matrix_shape
group.create_dataset('data', data=data.data, dtype=data_dtype, maxshape=(None,), chunks=True, compression=compression)
group.create_dataset('indices', data=data.indices, dtype=data.indices.dtype, maxshape=(None,), chunks=True, compression=compression)
group.create_dataset('indptr', data=data.indptr, dtype=data.indptr.dtype, maxshape=(None,), chunks=True, compression=compression)
self._write_elem(dest, data, compression=compression)
else:
raise NotImplementedError(f"Format must be 'dense', 'csr' or 'csc' but {format} given!")

Expand Down

0 comments on commit 12cde3e

Please sign in to comment.