Catch the user being remarkably foolish.
@@ -1392,6 +1392,10 @@ class UMAP(BaseEstimator):
# Handle other array dtypes (TODO: do this properly)
X = check_array(X, accept_sparse='csr').astype(np.float64)
+ if X.shape[0] <= n_neighbors:
+ raise ValueError('n_neighbors must be smaller than the dataset '
+ 'size!')
+
if scipy.sparse.isspmatrix_csr(X) and not X.has_sorted_indices:
X.sort_indices()
