#NEWLINE# def test_ckdtree_view( ) : #NEWLINE# #INDENT# np . random . seed ( 0 ) #NEWLINE# n = 100 #NEWLINE# k = 4 #NEWLINE# points = np . random . randn ( n , k ) #NEWLINE# kdtree = cKDTree ( points ) #NEWLINE# def recurse_tree( n ) : #NEWLINE# #INDENT# assert_ ( isinstance ( n , cKDTreeNode ) ) #NEWLINE# if ( n . split_dim == ( - 1 ) ) : #NEWLINE# #INDENT# assert_ ( ( n . lesser is None ) ) #NEWLINE# assert_ ( ( n . greater is None ) ) #NEWLINE# assert_ ( ( n . indices . shape [ 0 ] <= kdtree . leafsize ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# recurse_tree ( n . lesser ) #NEWLINE# recurse_tree ( n . greater ) #NEWLINE# x = n . lesser . data_points [ : , n . split_dim ] #NEWLINE# y = n . greater . data_points [ : , n . split_dim ] #NEWLINE# assert_ ( ( x . max ( ) < y . min ( ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# recurse_tree ( n . tree ) #NEWLINE# n = kdtree . tree #NEWLINE# assert_array_equal ( np . sort ( n . indices ) , range ( 100 ) ) #NEWLINE# assert_array_equal ( kdtree . data [ n . indices , : ] , n . data_points )