Skip to content

Commit

Permalink
Existing but empty raw layer must be recognized as no raw layer (#27)
Browse files Browse the repository at this point in the history
* Existing but empty raw layer must be recognized as no raw layer

* minor readme fix
  • Loading branch information
siberianisaev authored Sep 19, 2024
1 parent 655c85a commit 6ec655c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,9 @@ with read_h5ad(file_path, edit=True) as cap_adata:
sparse_dataset = cap_adata.layers["empty_sparse_matrix"]
sparse_dataset.append(chunk_data) # chunk_data must be 'csr' or 'csc' matrix

# Remove layer
cap_adata.remove_layer("dense_array")
with read_h5ad(file_path, edit=True) as cap_adata:
# Remove layer
cap_adata.remove_layer("dense_array")
```

#### 8. Join and Merge DataFrames
Expand Down
4 changes: 4 additions & 0 deletions cap_anndata/cap_anndata.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ def raw(self) -> RawLayer:
logger.warning("Can't read raw.var since raw layer doesn't exist!")
return

if len(self._file["raw"].keys()) == 0:
logger.warning("The raw layer is empty!")
return

self._raw = RawLayer(self._file)
return self._raw

Expand Down

0 comments on commit 6ec655c

Please sign in to comment.