Open gjhuizing opened 11 months ago
We only support matrices so far, and as far as I know, only one spot uses the axis
parameter. And we can support this use case in a different way.
the use case is a fast conversion from nearest neighbors csr_matrix to a pair of index/distance matrices. an alternative implementation is something like
-if is_constant(nns.getnnz(axis=1)):
+if is_constant(np.diff(nns.indptr)):
or so.
Please make sure these conditions are met
What happened?
Hi!
My recent PR (https://github.com/scverse/scanpy/pull/2772) made me realize that
.getnnz(axis=xx)
is used in several places in the codebase.From the Scipy docs for sparse arrays:
From what I understand, sparse matrices should be fine. Can we assume that an AnnData contains a sparse matrix and not a sparse array? If not, it may be good to do one or more of the following:
axis
argument is important to this widely used package. Pinging @dschult again for that.nnz
Best,
GJ
(edited because I originally confused
csr_array
andcsr_matrix
)Minimal code sample
Error output
No response
Versions