Created
January 23, 2012 23:51
-
-
Save jakevdp/1666570 to your computer and use it in GitHub Desktop.
Showing memory error in BallTree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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