Skip to content

Commit

Permalink
Bugfix: RAPIDS cuML no longer returns squared Euclidean distance matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
maximz committed Jan 6, 2022
1 parent 2c30784 commit b6bd872
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/release-notes/1.8.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Fixed finding variables with ``use_raw=True`` and ``basis=None`` in :func:`scanpy.pl.scatter` :pr:`2027` :small:`E Rice`
- Fixed :func:`scanpy.external.pp.scrublet` to address :issue:`1957` :smaller:`FlMai` and ensure raw counts are used for simulation
- Functions in :mod:`scanpy.datasets` no longer throw `OldFormatWarnings` when using `anndata` `0.8` :pr:`2096` :small:`I Virshup`
- Fixed use of :func:`scanpy.pp.neighbors` with ``method='rapids'``: RAPIDS cuML no longer returns a squared Euclidean distance matrix, so we should not square-root the kNN distance matrix. :pr:`1828` :small:`M Zaslavsky`

.. rubric:: Performance

Expand Down
4 changes: 2 additions & 2 deletions scanpy/neighbors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ def compute_neighbors_rapids(
nn = NearestNeighbors(n_neighbors=n_neighbors, metric=metric)
X_contiguous = np.ascontiguousarray(X, dtype=np.float32)
nn.fit(X_contiguous)
knn_distsq, knn_indices = nn.kneighbors(X_contiguous)
return knn_indices, np.sqrt(knn_distsq) # cuml uses sqeuclidean metric so take sqrt
knn_dist, knn_indices = nn.kneighbors(X_contiguous)
return knn_indices, knn_dist


def _get_sparse_matrix_from_indices_distances_umap(
Expand Down

0 comments on commit b6bd872

Please sign in to comment.