# Buggy code
def _init_umap(self, adata):
    from umap import UMAP

    self._umap = UMAP(metric=adata.uns["neighbors"]["params"]["metric"])

    self._umap.embedding_ = adata.obsm["X_umap"]
    self._umap._raw_data = self._rep
    self._umap._sparse_data = issparse(self._rep)
    self._umap._small_data = self._rep.shape[0] < 4096
    self._umap._metric_kwds = adata.uns["neighbors"]["params"].get("metric_kwds", {})
    self._umap._n_neighbors = adata.uns["neighbors"]["params"]["n_neighbors"]
    self._umap._initial_alpha = self._umap.learning_rate

    if self._random_init is not None or self._tree_init is not None:
        self._umap._random_init = self._random_init
        self._umap._tree_init = self._tree_init
        self._umap._search = self._search

    self._umap._rp_forest = self._rp_forest

    self._umap._search_graph = self._search_graph

    self._umap._a = adata.uns["umap"]["params"]["a"]
    self._umap._b = adata.uns["umap"]["params"]["b"]

    self._umap._input_hash = None


# Traceback (ImportError)
------------------------------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------------------------------
running ingest
______________________________________________________________________________________________________________ test_ingest_map_embedding_umap ______________________________________________________________________________________________________________

def test_ingest_map_embedding_umap():
adata_ref = sc.AnnData(X)
adata_new = sc.AnnData(T)

sc.pp.neighbors(
adata_ref, method='umap', use_rep='X', n_neighbors=4, random_state=0
)
sc.tl.umap(adata_ref, random_state=0)

ing = sc.tl.Ingest(adata_ref)

scanpy/tests/test_ingest.py:132:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
scanpy/tools/_ingest.py:270: in __init__
self._init_neighbors(adata)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <scanpy.tools._ingest.Ingest object at 0x140357550>, adata = AnnData object with n_obs × n_vars = 6 × 5
uns: 'neighbors', 'umap'
obsm: 'X_umap'

def _init_neighbors(self, adata):
from umap.distances import named_distances
from umap.nndescent import (
make_initialisations,
make_initialized_nnd_search,
)
E       ImportError: cannot import name 'make_initialisations' from 'umap.nndescent' (/usr/local/lib/python3.7/site-packages/umap/nndescent.py)

scanpy/tools/_ingest.py:210: ImportError

# Fixed code
def _init_umap(self, adata):
    from umap import UMAP

    self._umap = UMAP(
        metric=adata.uns["neighbors"]["params"]["metric"],
        random_state=adata.uns["umap"]["params"].get("random_state", 0),
    )

    self._umap.embedding_ = adata.obsm["X_umap"]
    self._umap._raw_data = self._rep
    self._umap._sparse_data = issparse(self._rep)
    self._umap._small_data = self._rep.shape[0] < 4096
    self._umap._metric_kwds = adata.uns["neighbors"]["params"].get("metric_kwds", {})
    self._umap._n_neighbors = adata.uns["neighbors"]["params"]["n_neighbors"]
    self._umap._initial_alpha = self._umap.learning_rate

    if self._random_init is not None or self._tree_init is not None:
        self._umap._random_init = self._random_init
        self._umap._tree_init = self._tree_init
        self._umap._search = self._search

    self._umap._rp_forest = self._rp_forest

    self._umap._search_graph = self._search_graph

    self._umap._a = adata.uns["umap"]["params"]["a"]
    self._umap._b = adata.uns["umap"]["params"]["b"]

    self._umap._input_hash = None