Skip to content

Commit

Permalink
Don't fail hard in case of issue #17
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcinnes committed Nov 14, 2017
1 parent ab32afc commit ba31ce1
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions umap/umap_.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,17 @@ def heap_push(heap, row, weight, index, flag):

def rptree_leaf_array(data, n_neighbors, n_trees=10):
leaves = []
leaf_size = max(10, n_neighbors)
for t in range(n_trees):
tree = make_tree(data, np.arange(data.shape[0]), leaf_size=leaf_size)
leaves += get_leaves(tree)

leaf_array = -1 * np.ones([len(leaves), leaf_size], dtype=np.int64)
for i, leaf in enumerate(leaves):
leaf_array[i, :len(leaf)] = leaf
try:
leaf_size = max(10, n_neighbors)
for t in range(n_trees):
tree = make_tree(data, np.arange(data.shape[0]), leaf_size=leaf_size)
leaves += get_leaves(tree)

leaf_array = -1 * np.ones([len(leaves), leaf_size], dtype=np.int64)
for i, leaf in enumerate(leaves):
leaf_array[i, :len(leaf)] = leaf
except RecursionError:
leaf_array = np.array([[-1]])

return leaf_array

Expand Down

0 comments on commit ba31ce1

Please sign in to comment.