We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
sc.tl.umap error with init_pos="paga"
Hello,

Trying to use sc.tl.umap with initial positions from sc.tl.paga. Seems an error with UMAP from the error log. But it is only called when calling paga positions, UMAP works otherwise.

I do see https://github.com/theislab/scanpy/issues/666, and https://github.com/lmcinnes/umap/pull/262, but I am already running scanpy 1.4.4 and umap 0.3.9 so I don't understand how to solve the issue?

Attached error. Any suggestions? 
Thanks!

<img width="575" alt="Screen Shot 2019-08-05 at 19 02 18" src="https://user-images.githubusercontent.com/20108378/62485139-c560df80-b7b3-11e9-8333-7e511c263a79.png">


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `scanpy/tools/_umap.py`
Content:
```
1 import numpy as np
2 from pandas.api.types import is_numeric_dtype
3 from sklearn.utils import check_random_state, check_array
4 
5 from ._utils import get_init_pos_from_paga, choose_representation
6 from .._settings import settings
7 from .. import logging as logg
8 
9 
10 def umap(
11     adata,
12     min_dist=0.5,
13     spread=1.0,
14     n_components=2,
15     maxiter=None,
16     alpha=1.0,
17     gamma=1.0,
18     negative_sample_rate=5,
19     init_pos='spectral',
20     random_state=0,
21     a=None,
22     b=None,
23     copy=False,
24 ):
25     """Embed the neighborhood graph using UMAP [McInnes18]_.
26 
27     UMAP (Uniform Manifold Approximation and Projection) is a manifold learning
28     technique suitable for visualizing high-dimensional data. Besides tending to
29     be faster than tSNE, it optimizes the embedding such that it best reflects
30     the topology of the data, which we represent throughout Scanpy using a
31     neighborhood graph. tSNE, by contrast, optimizes the distribution of
32     nearest-neighbor distances in the embedding such that these best match the
33     distribution of distances in the high-dimensional space.  We use the
34     implementation of `umap-learn <https://github.com/lmcinnes/umap>`__
35     [McInnes18]_. For a few comparisons of UMAP with tSNE, see this `preprint
36     <https://doi.org/10.1101/298430>`__.
37 
38     Parameters
39     ----------
40     adata : :class:`~anndata.AnnData`
41         Annotated data matrix.
42     min_dist : `float`, optional (default: 0.5)
43         The effective minimum distance between embedded points. Smaller values
44         will result in a more clustered/clumped embedding where nearby points on
45         the manifold are drawn closer together, while larger values will result
46         on a more even dispersal of points. The value should be set relative to
47         the ``spread`` value, which determines the scale at which embedded
48         points will be spread out. The default of in the `umap-learn` package is
49         0.1.
50     spread : `float` (optional, default 1.0)
51         The effective scale of embedded points. In combination with `min_dist`
52         this determines how clustered/clumped the embedded points are.
53     n_components : `int`, optional (default: 2)
54         The number of dimensions of the embedding.
55     maxiter : `int`, optional (default: `None`)
56         The number of iterations (epochs) of the optimization. Called `n_epochs`
57         in the original UMAP.
58     alpha : `float`, optional (default: 1.0)
59         The initial learning rate for the embedding optimization.
60     gamma : `float` (optional, default 1.0)
61         Weighting applied to negative samples in low dimensional embedding
62         optimization. Values higher than one will result in greater weight
63         being given to negative samples.
64     negative_sample_rate : `int` (optional, default 5)
65         The number of negative edge/1-simplex samples to use per positive
66         edge/1-simplex sample in optimizing the low dimensional embedding.
67     init_pos : `string` or `np.array`, optional (default: 'spectral')
68         How to initialize the low dimensional embedding. Called `init` in the
69         original UMAP.
70         Options are:
71 
72         * Any key for `adata.obsm`.
73         * 'paga': positions from :func:`~scanpy.api.pl.paga`.
74         * 'spectral': use a spectral embedding of the graph.
75         * 'random': assign initial embedding positions at random.
76         * A numpy array of initial embedding positions.
77     random_state : `int`, `RandomState` or `None`, optional (default: 0)
78         If `int`, `random_state` is the seed used by the random number generator;
79         If `RandomState`, `random_state` is the random number generator;
80         If `None`, the random number generator is the `RandomState` instance used
81         by `np.random`.
82     a : `float` (optional, default `None`)
83         More specific parameters controlling the embedding. If `None` these
84         values are set automatically as determined by `min_dist` and
85         `spread`.
86     b : `float` (optional, default `None`)
87         More specific parameters controlling the embedding. If `None` these
88         values are set automatically as determined by `min_dist` and
89         `spread`.
90     copy : `bool` (default: `False`)
91         Return a copy instead of writing to adata.
92 
93     Returns
94     -------
95     Depending on `copy`, returns or updates `adata` with the following fields.
96 
97     **X_umap** : `adata.obsm` field
98         UMAP coordinates of data.
99     """
100     adata = adata.copy() if copy else adata
101     if 'neighbors' not in adata.uns:
102         raise ValueError(
103             'Did not find \'neighbors/connectivities\'. Run `sc.pp.neighbors` first.')
104     start = logg.info('computing UMAP')
105     if ('params' not in adata.uns['neighbors']
106         or adata.uns['neighbors']['params']['method'] != 'umap'):
107         logg.warning('neighbors/connectivities have not been computed using umap')
108     from umap.umap_ import find_ab_params, simplicial_set_embedding
109     if a is None or b is None:
110         a, b = find_ab_params(spread, min_dist)
111     else:
112         a = a
113         b = b
114 
115     if isinstance(init_pos, str) and init_pos in adata.obsm.keys():
116         init_coords = adata.obsm[init_pos]
117     elif isinstance(init_pos, str) and init_pos == 'paga':
118         init_coords = get_init_pos_from_paga(adata, random_state=random_state)
119     else:
120         init_coords = init_pos  # Let umap handle it
121     if hasattr(init_coords, "dtype") and is_numeric_dtype(init_pos):
122         init_coords = check_array(init_coords, dtype=np.float32, accept_sparse=False)
123 
124     random_state = check_random_state(random_state)
125     n_epochs = 0 if maxiter is None else maxiter
126     neigh_params = adata.uns['neighbors']['params']
127     X = choose_representation(
128         adata, neigh_params.get('use_rep', None), neigh_params.get('n_pcs', None), silent=True)
129     # the data matrix X is really only used for determining the number of connected components
130     # for the init condition in the UMAP embedding
131     X_umap = simplicial_set_embedding(
132         X,
133         adata.uns['neighbors']['connectivities'].tocoo(),
134         n_components,
135         alpha,
136         a,
137         b,
138         gamma,
139         negative_sample_rate,
140         n_epochs,
141         init_coords,
142         random_state,
143         neigh_params.get('metric', 'euclidean'),
144         neigh_params.get('metric_kwds', {}),
145         verbose=settings.verbosity > 3,
146     )
147     adata.obsm['X_umap'] = X_umap  # annotate samples with UMAP coordinates
148     logg.info(
149         '    finished',
150         time=start,
151         deep=(
152             'added\n'
153             "    'X_umap', UMAP coordinates (adata.obsm)"
154         ),
155     )
156     return adata if copy else None
157
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/scanpy/tools/_umap.py b/scanpy/tools/_umap.py
--- a/scanpy/tools/_umap.py
+++ b/scanpy/tools/_umap.py
@@ -118,7 +118,7 @@
         init_coords = get_init_pos_from_paga(adata, random_state=random_state)
     else:
         init_coords = init_pos  # Let umap handle it
-    if hasattr(init_coords, "dtype") and is_numeric_dtype(init_pos):
+    if hasattr(init_coords, "dtype"):
         init_coords = check_array(init_coords, dtype=np.float32, accept_sparse=False)
 
     random_state = check_random_state(random_state)

{"golden_diff": "diff --git a/scanpy/tools/_umap.py b/scanpy/tools/_umap.py\n--- a/scanpy/tools/_umap.py\n+++ b/scanpy/tools/_umap.py\n@@ -118,7 +118,7 @@\n         init_coords = get_init_pos_from_paga(adata, random_state=random_state)\n     else:\n         init_coords = init_pos  # Let umap handle it\n-    if hasattr(init_coords, \"dtype\") and is_numeric_dtype(init_pos):\n+    if hasattr(init_coords, \"dtype\"):\n         init_coords = check_array(init_coords, dtype=np.float32, accept_sparse=False)\n \n     random_state = check_random_state(random_state)\n", "issue": "sc.tl.umap error with init_pos=\"paga\"\nHello,\r\n\r\nTrying to use sc.tl.umap with initial positions from sc.tl.paga. Seems an error with UMAP from the error log. But it is only called when calling paga positions, UMAP works otherwise.\r\n\r\nI do see https://github.com/theislab/scanpy/issues/666, and https://github.com/lmcinnes/umap/pull/262, but I am already running scanpy 1.4.4 and umap 0.3.9 so I don't understand how to solve the issue?\r\n\r\nAttached error. Any suggestions? \r\nThanks!\r\n\r\n<img width=\"575\" alt=\"Screen Shot 2019-08-05 at 19 02 18\" src=\"https://user-images.githubusercontent.com/20108378/62485139-c560df80-b7b3-11e9-8333-7e511c263a79.png\">\r\n\n", "before_files": [{"content": "import numpy as np\nfrom pandas.api.types import is_numeric_dtype\nfrom sklearn.utils import check_random_state, check_array\n\nfrom ._utils import get_init_pos_from_paga, choose_representation\nfrom .._settings import settings\nfrom .. import logging as logg\n\n\ndef umap(\n    adata,\n    min_dist=0.5,\n    spread=1.0,\n    n_components=2,\n    maxiter=None,\n    alpha=1.0,\n    gamma=1.0,\n    negative_sample_rate=5,\n    init_pos='spectral',\n    random_state=0,\n    a=None,\n    b=None,\n    copy=False,\n):\n    \"\"\"Embed the neighborhood graph using UMAP [McInnes18]_.\n\n    UMAP (Uniform Manifold Approximation and Projection) is a manifold learning\n    technique suitable for visualizing high-dimensional data. Besides tending to\n    be faster than tSNE, it optimizes the embedding such that it best reflects\n    the topology of the data, which we represent throughout Scanpy using a\n    neighborhood graph. tSNE, by contrast, optimizes the distribution of\n    nearest-neighbor distances in the embedding such that these best match the\n    distribution of distances in the high-dimensional space.  We use the\n    implementation of `umap-learn <https://github.com/lmcinnes/umap>`__\n    [McInnes18]_. For a few comparisons of UMAP with tSNE, see this `preprint\n    <https://doi.org/10.1101/298430>`__.\n\n    Parameters\n    ----------\n    adata : :class:`~anndata.AnnData`\n        Annotated data matrix.\n    min_dist : `float`, optional (default: 0.5)\n        The effective minimum distance between embedded points. Smaller values\n        will result in a more clustered/clumped embedding where nearby points on\n        the manifold are drawn closer together, while larger values will result\n        on a more even dispersal of points. The value should be set relative to\n        the ``spread`` value, which determines the scale at which embedded\n        points will be spread out. The default of in the `umap-learn` package is\n        0.1.\n    spread : `float` (optional, default 1.0)\n        The effective scale of embedded points. In combination with `min_dist`\n        this determines how clustered/clumped the embedded points are.\n    n_components : `int`, optional (default: 2)\n        The number of dimensions of the embedding.\n    maxiter : `int`, optional (default: `None`)\n        The number of iterations (epochs) of the optimization. Called `n_epochs`\n        in the original UMAP.\n    alpha : `float`, optional (default: 1.0)\n        The initial learning rate for the embedding optimization.\n    gamma : `float` (optional, default 1.0)\n        Weighting applied to negative samples in low dimensional embedding\n        optimization. Values higher than one will result in greater weight\n        being given to negative samples.\n    negative_sample_rate : `int` (optional, default 5)\n        The number of negative edge/1-simplex samples to use per positive\n        edge/1-simplex sample in optimizing the low dimensional embedding.\n    init_pos : `string` or `np.array`, optional (default: 'spectral')\n        How to initialize the low dimensional embedding. Called `init` in the\n        original UMAP.\n        Options are:\n\n        * Any key for `adata.obsm`.\n        * 'paga': positions from :func:`~scanpy.api.pl.paga`.\n        * 'spectral': use a spectral embedding of the graph.\n        * 'random': assign initial embedding positions at random.\n        * A numpy array of initial embedding positions.\n    random_state : `int`, `RandomState` or `None`, optional (default: 0)\n        If `int`, `random_state` is the seed used by the random number generator;\n        If `RandomState`, `random_state` is the random number generator;\n        If `None`, the random number generator is the `RandomState` instance used\n        by `np.random`.\n    a : `float` (optional, default `None`)\n        More specific parameters controlling the embedding. If `None` these\n        values are set automatically as determined by `min_dist` and\n        `spread`.\n    b : `float` (optional, default `None`)\n        More specific parameters controlling the embedding. If `None` these\n        values are set automatically as determined by `min_dist` and\n        `spread`.\n    copy : `bool` (default: `False`)\n        Return a copy instead of writing to adata.\n\n    Returns\n    -------\n    Depending on `copy`, returns or updates `adata` with the following fields.\n\n    **X_umap** : `adata.obsm` field\n        UMAP coordinates of data.\n    \"\"\"\n    adata = adata.copy() if copy else adata\n    if 'neighbors' not in adata.uns:\n        raise ValueError(\n            'Did not find \\'neighbors/connectivities\\'. Run `sc.pp.neighbors` first.')\n    start = logg.info('computing UMAP')\n    if ('params' not in adata.uns['neighbors']\n        or adata.uns['neighbors']['params']['method'] != 'umap'):\n        logg.warning('neighbors/connectivities have not been computed using umap')\n    from umap.umap_ import find_ab_params, simplicial_set_embedding\n    if a is None or b is None:\n        a, b = find_ab_params(spread, min_dist)\n    else:\n        a = a\n        b = b\n\n    if isinstance(init_pos, str) and init_pos in adata.obsm.keys():\n        init_coords = adata.obsm[init_pos]\n    elif isinstance(init_pos, str) and init_pos == 'paga':\n        init_coords = get_init_pos_from_paga(adata, random_state=random_state)\n    else:\n        init_coords = init_pos  # Let umap handle it\n    if hasattr(init_coords, \"dtype\") and is_numeric_dtype(init_pos):\n        init_coords = check_array(init_coords, dtype=np.float32, accept_sparse=False)\n\n    random_state = check_random_state(random_state)\n    n_epochs = 0 if maxiter is None else maxiter\n    neigh_params = adata.uns['neighbors']['params']\n    X = choose_representation(\n        adata, neigh_params.get('use_rep', None), neigh_params.get('n_pcs', None), silent=True)\n    # the data matrix X is really only used for determining the number of connected components\n    # for the init condition in the UMAP embedding\n    X_umap = simplicial_set_embedding(\n        X,\n        adata.uns['neighbors']['connectivities'].tocoo(),\n        n_components,\n        alpha,\n        a,\n        b,\n        gamma,\n        negative_sample_rate,\n        n_epochs,\n        init_coords,\n        random_state,\n        neigh_params.get('metric', 'euclidean'),\n        neigh_params.get('metric_kwds', {}),\n        verbose=settings.verbosity > 3,\n    )\n    adata.obsm['X_umap'] = X_umap  # annotate samples with UMAP coordinates\n    logg.info(\n        '    finished',\n        time=start,\n        deep=(\n            'added\\n'\n            \"    'X_umap', UMAP coordinates (adata.obsm)\"\n        ),\n    )\n    return adata if copy else None\n", "path": "scanpy/tools/_umap.py"}], "after_files": [{"content": "import numpy as np\nfrom pandas.api.types import is_numeric_dtype\nfrom sklearn.utils import check_random_state, check_array\n\nfrom ._utils import get_init_pos_from_paga, choose_representation\nfrom .._settings import settings\nfrom .. import logging as logg\n\n\ndef umap(\n    adata,\n    min_dist=0.5,\n    spread=1.0,\n    n_components=2,\n    maxiter=None,\n    alpha=1.0,\n    gamma=1.0,\n    negative_sample_rate=5,\n    init_pos='spectral',\n    random_state=0,\n    a=None,\n    b=None,\n    copy=False,\n):\n    \"\"\"Embed the neighborhood graph using UMAP [McInnes18]_.\n\n    UMAP (Uniform Manifold Approximation and Projection) is a manifold learning\n    technique suitable for visualizing high-dimensional data. Besides tending to\n    be faster than tSNE, it optimizes the embedding such that it best reflects\n    the topology of the data, which we represent throughout Scanpy using a\n    neighborhood graph. tSNE, by contrast, optimizes the distribution of\n    nearest-neighbor distances in the embedding such that these best match the\n    distribution of distances in the high-dimensional space.  We use the\n    implementation of `umap-learn <https://github.com/lmcinnes/umap>`__\n    [McInnes18]_. For a few comparisons of UMAP with tSNE, see this `preprint\n    <https://doi.org/10.1101/298430>`__.\n\n    Parameters\n    ----------\n    adata : :class:`~anndata.AnnData`\n        Annotated data matrix.\n    min_dist : `float`, optional (default: 0.5)\n        The effective minimum distance between embedded points. Smaller values\n        will result in a more clustered/clumped embedding where nearby points on\n        the manifold are drawn closer together, while larger values will result\n        on a more even dispersal of points. The value should be set relative to\n        the ``spread`` value, which determines the scale at which embedded\n        points will be spread out. The default of in the `umap-learn` package is\n        0.1.\n    spread : `float` (optional, default 1.0)\n        The effective scale of embedded points. In combination with `min_dist`\n        this determines how clustered/clumped the embedded points are.\n    n_components : `int`, optional (default: 2)\n        The number of dimensions of the embedding.\n    maxiter : `int`, optional (default: `None`)\n        The number of iterations (epochs) of the optimization. Called `n_epochs`\n        in the original UMAP.\n    alpha : `float`, optional (default: 1.0)\n        The initial learning rate for the embedding optimization.\n    gamma : `float` (optional, default 1.0)\n        Weighting applied to negative samples in low dimensional embedding\n        optimization. Values higher than one will result in greater weight\n        being given to negative samples.\n    negative_sample_rate : `int` (optional, default 5)\n        The number of negative edge/1-simplex samples to use per positive\n        edge/1-simplex sample in optimizing the low dimensional embedding.\n    init_pos : `string` or `np.array`, optional (default: 'spectral')\n        How to initialize the low dimensional embedding. Called `init` in the\n        original UMAP.\n        Options are:\n\n        * Any key for `adata.obsm`.\n        * 'paga': positions from :func:`~scanpy.api.pl.paga`.\n        * 'spectral': use a spectral embedding of the graph.\n        * 'random': assign initial embedding positions at random.\n        * A numpy array of initial embedding positions.\n    random_state : `int`, `RandomState` or `None`, optional (default: 0)\n        If `int`, `random_state` is the seed used by the random number generator;\n        If `RandomState`, `random_state` is the random number generator;\n        If `None`, the random number generator is the `RandomState` instance used\n        by `np.random`.\n    a : `float` (optional, default `None`)\n        More specific parameters controlling the embedding. If `None` these\n        values are set automatically as determined by `min_dist` and\n        `spread`.\n    b : `float` (optional, default `None`)\n        More specific parameters controlling the embedding. If `None` these\n        values are set automatically as determined by `min_dist` and\n        `spread`.\n    copy : `bool` (default: `False`)\n        Return a copy instead of writing to adata.\n\n    Returns\n    -------\n    Depending on `copy`, returns or updates `adata` with the following fields.\n\n    **X_umap** : `adata.obsm` field\n        UMAP coordinates of data.\n    \"\"\"\n    adata = adata.copy() if copy else adata\n    if 'neighbors' not in adata.uns:\n        raise ValueError(\n            'Did not find \\'neighbors/connectivities\\'. Run `sc.pp.neighbors` first.')\n    start = logg.info('computing UMAP')\n    if ('params' not in adata.uns['neighbors']\n        or adata.uns['neighbors']['params']['method'] != 'umap'):\n        logg.warning('neighbors/connectivities have not been computed using umap')\n    from umap.umap_ import find_ab_params, simplicial_set_embedding\n    if a is None or b is None:\n        a, b = find_ab_params(spread, min_dist)\n    else:\n        a = a\n        b = b\n\n    if isinstance(init_pos, str) and init_pos in adata.obsm.keys():\n        init_coords = adata.obsm[init_pos]\n    elif isinstance(init_pos, str) and init_pos == 'paga':\n        init_coords = get_init_pos_from_paga(adata, random_state=random_state)\n    else:\n        init_coords = init_pos  # Let umap handle it\n    if hasattr(init_coords, \"dtype\"):\n        init_coords = check_array(init_coords, dtype=np.float32, accept_sparse=False)\n\n    random_state = check_random_state(random_state)\n    n_epochs = 0 if maxiter is None else maxiter\n    neigh_params = adata.uns['neighbors']['params']\n    X = choose_representation(\n        adata, neigh_params.get('use_rep', None), neigh_params.get('n_pcs', None), silent=True)\n    # the data matrix X is really only used for determining the number of connected components\n    # for the init condition in the UMAP embedding\n    X_umap = simplicial_set_embedding(\n        X,\n        adata.uns['neighbors']['connectivities'].tocoo(),\n        n_components,\n        alpha,\n        a,\n        b,\n        gamma,\n        negative_sample_rate,\n        n_epochs,\n        init_coords,\n        random_state,\n        neigh_params.get('metric', 'euclidean'),\n        neigh_params.get('metric_kwds', {}),\n        verbose=settings.verbosity > 3,\n    )\n    adata.obsm['X_umap'] = X_umap  # annotate samples with UMAP coordinates\n    logg.info(\n        '    finished',\n        time=start,\n        deep=(\n            'added\\n'\n            \"    'X_umap', UMAP coordinates (adata.obsm)\"\n        ),\n    )\n    return adata if copy else None\n", "path": "scanpy/tools/_umap.py"}]}