Skip to content

fix: copy connectivities before passing to umap-learn#4031

Open
nbjustice wants to merge 1 commit intoscverse:mainfrom
nbjustice:fix/umap-connectivities-copy-4028
Open

fix: copy connectivities before passing to umap-learn#4031
nbjustice wants to merge 1 commit intoscverse:mainfrom
nbjustice:fix/umap-connectivities-copy-4028

Conversation

@nbjustice
Copy link
Copy Markdown

Summary

sc.tl.umap() passes neighbors["connectivities"].tocoo() to umap-learn's simplicial_set_embedding() without copying. Since csr_matrix.tocoo() defaults to copy=False, the COO and CSR matrices share the same data buffer. umap-learn then zeroes out small edge weights in-place, which silently corrupts adata.obsp['connectivities'].

Fix: .tocoo().tocoo(copy=True)

Test plan

  • Added test_umap_preserves_connectivities asserting data values, nnz count, no explicit zeros, and embedding is still produced
  • Verified test fails without the fix and passes with it
  • All existing UMAP tests pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sc.tl.umap() silently mutates adata.obsp['connectivities'] via shared sparse buffer

1 participant