Skip to content

Commit bf58465

Browse files
alexandercboothlesteve
authored andcommitted
[MRG] make doctests Python 3 compatible (scikit-learn#7906)
1 parent 3292f2d commit bf58465

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

sklearn/neighbors/binary_tree.pxi

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ Query for k-nearest neighbors
297297
>>> X = np.random.random((10, 3)) # 10 points in 3 dimensions
298298
>>> tree = {BinaryTree}(X, leaf_size=2) # doctest: +SKIP
299299
>>> dist, ind = tree.query([X[0]], k=3) # doctest: +SKIP
300-
>>> print ind # indices of 3 closest neighbors
300+
>>> print(ind) # indices of 3 closest neighbors
301301
[0 3 1]
302-
>>> print dist # distances to 3 closest neighbors
302+
>>> print(dist) # distances to 3 closest neighbors
303303
[ 0. 0.19662693 0.29473397]
304304
305305
Pickle and Unpickle a tree. Note that the state of the tree is saved in the
@@ -313,9 +313,9 @@ pickle operation: the tree needs not be rebuilt upon unpickling.
313313
>>> s = pickle.dumps(tree) # doctest: +SKIP
314314
>>> tree_copy = pickle.loads(s) # doctest: +SKIP
315315
>>> dist, ind = tree_copy.query(X[0], k=3) # doctest: +SKIP
316-
>>> print ind # indices of 3 closest neighbors
316+
>>> print(ind) # indices of 3 closest neighbors
317317
[0 3 1]
318-
>>> print dist # distances to 3 closest neighbors
318+
>>> print(dist) # distances to 3 closest neighbors
319319
[ 0. 0.19662693 0.29473397]
320320
321321
Query for neighbors within a given radius
@@ -324,10 +324,10 @@ Query for neighbors within a given radius
324324
>>> np.random.seed(0)
325325
>>> X = np.random.random((10, 3)) # 10 points in 3 dimensions
326326
>>> tree = {BinaryTree}(X, leaf_size=2) # doctest: +SKIP
327-
>>> print tree.query_radius(X[0], r=0.3, count_only=True)
327+
>>> print(tree.query_radius(X[0], r=0.3, count_only=True))
328328
3
329329
>>> ind = tree.query_radius(X[0], r=0.3) # doctest: +SKIP
330-
>>> print ind # indices of neighbors within distance 0.3
330+
>>> print(ind) # indices of neighbors within distance 0.3
331331
[3 0 1]
332332
333333
@@ -623,7 +623,7 @@ cdef class NeighborsHeap:
623623
dist_arr[0] = val
624624
ind_arr[0] = i_val
625625

626-
#descend the heap, swapping values until the max heap criterion is met
626+
# descend the heap, swapping values until the max heap criterion is met
627627
i = 0
628628
while True:
629629
ic1 = 2 * i + 1
@@ -1282,9 +1282,9 @@ cdef class BinaryTree:
12821282
>>> X = np.random.random((10, 3)) # 10 points in 3 dimensions
12831283
>>> tree = BinaryTree(X, leaf_size=2) # doctest: +SKIP
12841284
>>> dist, ind = tree.query(X[0], k=3) # doctest: +SKIP
1285-
>>> print ind # indices of 3 closest neighbors
1285+
>>> print(ind) # indices of 3 closest neighbors
12861286
[0 3 1]
1287-
>>> print dist # distances to 3 closest neighbors
1287+
>>> print(dist) # distances to 3 closest neighbors
12881288
[ 0. 0.19662693 0.29473397]
12891289
"""
12901290
# XXX: we should allow X to be a pre-built tree.
@@ -1415,10 +1415,10 @@ cdef class BinaryTree:
14151415
>>> np.random.seed(0)
14161416
>>> X = np.random.random((10, 3)) # 10 points in 3 dimensions
14171417
>>> tree = BinaryTree(X, leaf_size=2) # doctest: +SKIP
1418-
>>> print tree.query_radius(X[0], r=0.3, count_only=True)
1418+
>>> print(tree.query_radius(X[0], r=0.3, count_only=True))
14191419
3
14201420
>>> ind = tree.query_radius(X[0], r=0.3) # doctest: +SKIP
1421-
>>> print ind # indices of neighbors within distance 0.3
1421+
>>> print(ind) # indices of neighbors within distance 0.3
14221422
[3 0 1]
14231423
"""
14241424
if count_only and return_distance:

0 commit comments

Comments
 (0)