Don't fail hard in case of issue
@@ -187,6 +187,7 @@ def heap_push(heap, row, weight, index, flag):
def rptree_leaf_array(data, n_neighbors, n_trees=10):
leaves = []
+ 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)
@@ -195,6 +196,8 @@ def rptree_leaf_array(data, n_neighbors, n_trees=10):
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
