From e6f3c0deb1e59077b0390c3585fe66ce7f100227 Mon Sep 17 00:00:00 2001 From: Intron7 Date: Mon, 16 Dec 2024 17:46:01 +0100 Subject: [PATCH] add update --- src/rapids_singlecell/preprocessing/_normalize.py | 4 +++- .../preprocessing/_sparse_pca/_sparse_pca.py | 2 ++ src/rapids_singlecell/preprocessing/_utils.py | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/rapids_singlecell/preprocessing/_normalize.py b/src/rapids_singlecell/preprocessing/_normalize.py index 1acf9dd3..e4f92912 100644 --- a/src/rapids_singlecell/preprocessing/_normalize.py +++ b/src/rapids_singlecell/preprocessing/_normalize.py @@ -88,7 +88,7 @@ def _normalize_total(X: ArrayTypesDask, target_sum: int): return _normalize_total_csr(X, target_sum) elif isinstance(X, DaskArray): return _normalize_total_dask(X, target_sum) - else: + elif isinstance(X, cp.ndarray): from ._kernels._norm_kernel import _mul_dense if not X.flags.c_contiguous: @@ -100,6 +100,8 @@ def _normalize_total(X: ArrayTypesDask, target_sum: int): (X, X.shape[0], X.shape[1], int(target_sum)), ) return X + else: + raise ValueError(f"Cannot normalize {type(X)}") def _normalize_total_csr(X: sparse.csr_matrix, target_sum: int) -> sparse.csr_matrix: diff --git a/src/rapids_singlecell/preprocessing/_sparse_pca/_sparse_pca.py b/src/rapids_singlecell/preprocessing/_sparse_pca/_sparse_pca.py index 2f9d5117..1c9fa84d 100644 --- a/src/rapids_singlecell/preprocessing/_sparse_pca/_sparse_pca.py +++ b/src/rapids_singlecell/preprocessing/_sparse_pca/_sparse_pca.py @@ -1,3 +1,5 @@ +# This file will be removed in Q3 2025 when in favor of the CUML implementation + from __future__ import annotations import math diff --git a/src/rapids_singlecell/preprocessing/_utils.py b/src/rapids_singlecell/preprocessing/_utils.py index 09e8eb43..10db5518 100644 --- a/src/rapids_singlecell/preprocessing/_utils.py +++ b/src/rapids_singlecell/preprocessing/_utils.py @@ -231,6 +231,8 @@ def _get_mean_var(X, axis=0): major = X.shape[1] minor = X.shape[0] mean, var = _mean_var_minor(X, major, minor) + else: + raise ValueError("axis must be either 0 or 1") elif isinstance(X, DaskArray): if isspmatrix_csr(X._meta): if axis == 0: @@ -243,6 +245,10 @@ def _get_mean_var(X, axis=0): mean, var = _mean_var_major_dask(X, major, minor) elif isinstance(X._meta, cp.ndarray): mean, var = _mean_var_dense_dask(X, axis) + else: + raise ValueError( + "Type not supported. Please provide a CuPy ndarray or a CuPy sparse matrix. Or a Dask array with a CuPy ndarray or a CuPy sparse matrix as meta." + ) else: mean, var = _mean_var_dense(X, axis) return mean, var