Skip to content

Commit 3a20dc2

Browse files
committed
fix pointer
1 parent 4876400 commit 3a20dc2

File tree

1 file changed

+8
-7
lines changed
  • src/rapids_singlecell/preprocessing/_sparse_pca

1 file changed

+8
-7
lines changed

src/rapids_singlecell/preprocessing/_sparse_pca/_helper.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ def _compute_cov(
3939

4040
def _check_matrix_for_zero_genes(X: spmatrix) -> None:
4141
gene_ex = cp.zeros(X.shape[1], dtype=cp.int32)
42-
_spca.check_zero_genes(
43-
X.indices.data.ptr,
44-
gene_ex.data.ptr,
45-
int(X.nnz),
46-
int(X.shape[1]),
47-
int(cp.cuda.get_current_stream().ptr),
48-
)
42+
if X.nnz > 0:
43+
_spca.check_zero_genes(
44+
int(X.indices.data.ptr),
45+
int(gene_ex.data.ptr),
46+
int(X.nnz),
47+
int(X.shape[1]),
48+
int(cp.cuda.get_current_stream().ptr),
49+
)
4950
if cp.any(gene_ex == 0):
5051
raise ValueError(
5152
"There are genes with zero expression. Please remove them before running PCA."

0 commit comments

Comments
 (0)