Skip to content

Commit

Permalink
fix sparse X with sparse distance matrix for nn
Browse files Browse the repository at this point in the history
  • Loading branch information
jlmelville committed Dec 25, 2024
1 parent f1f5f4d commit c213dea
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions R/umap2.R
Original file line number Diff line number Diff line change
Expand Up @@ -750,14 +750,15 @@ umap2 <-
if (!methods::is(X, "dgCMatrix")) {
stop("sparse X must be a dgCMatrix object")
}
if (!is.list(nn_method)) {
if (!is.list(nn_method) && !is_sparse_matrix(nn_method)) {
if (!is_installed("rnndescent")) {
stop(
"nearest neighbor search for sparse matrices requires the ",
"'rnndescent' package, please install it"
)
}
if (!is.null(nn_method) && nn_method != "nndescent") {
if (!is.null(nn_method) &&
is.character(nn_method) && nn_method != "nndescent") {
stop(
"nearest neighbor search for sparse matrices only supports ",
"the 'nndescent' method"
Expand Down

0 comments on commit c213dea

Please sign in to comment.