Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jakevdp
Created January 23, 2012 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakevdp/1666570 to your computer and use it in GitHub Desktop.
Save jakevdp/1666570 to your computer and use it in GitHub Desktop.
Showing memory error in BallTree
import warnings
from sklearn import datasets
from sklearn.neighbors import NearestNeighbors
import numpy as np
n_points = 1000
n_neighbors = 10
out_dim = 2
n_trials = 100
X, _ = datasets.samples_generator.make_s_curve(n_points, random_state=123)
knn = NearestNeighbors(n_neighbors)
for i in xrange(n_trials):
print i + 1
knn.fit(X)
#print X # <-- uncomment this line and the test will no longer fail.
with warnings.catch_warnings(record=True) as w:
knn.kneighbors(X)
assert(len(w) == 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment