#NEWLINE# def test_storage_memory( self ) : #NEWLINE# #INDENT# rbpt = RandomBinaryProjectionTree ( 'testHash' , 10 , 20 ) #NEWLINE# self . engine = Engine ( 100 , lshashes = [ rbpt ] , vector_filters = [ NearestFilter ( 20 ) ] ) #NEWLINE# for k in range ( 2000 ) : #NEWLINE# #INDENT# x = numpy . random . randn ( 100 ) #NEWLINE# x_data = 'data' #NEWLINE# self . engine . store_vector ( x , x_data ) #NEWLINE# #UNINDENT# self . memory . store_hash_configuration ( rbpt ) #NEWLINE# rbpt2 = RandomBinaryProjectionTree ( None , None , None ) #NEWLINE# rbpt2 . apply_config ( self . memory . load_hash_configuration ( 'testHash' ) ) #NEWLINE# self . assertEqual ( rbpt . dim , rbpt2 . dim ) #NEWLINE# self . assertEqual ( rbpt . hash_name , rbpt2 . hash_name ) #NEWLINE# self . assertEqual ( rbpt . projection_count , rbpt2 . projection_count ) #NEWLINE# for i in range ( rbpt . normals . shape [ 0 ] ) : #NEWLINE# #INDENT# for j in range ( rbpt . normals . shape [ 1 ] ) : #NEWLINE# #INDENT# self . assertEqual ( rbpt . normals [ ( i , j ) ] , rbpt2 . normals [ ( i , j ) ] ) #NEWLINE# #UNINDENT# #UNINDENT# for k in range ( 10 ) : #NEWLINE# #INDENT# x = numpy . random . randn ( 100 ) #NEWLINE# keys1 = rbpt . hash_vector ( x , querying = True ) #NEWLINE# keys2 = rbpt2 . hash_vector ( x , querying = True ) #NEWLINE# self . assertEqual ( len ( keys1 ) , len ( keys2 ) ) #NEWLINE# for k in range ( len ( keys1 ) ) : #NEWLINE# #INDENT# self . assertEqual ( keys1 [ k ] , keys2 [ k ] )