#NEWLINE# def testMmap( self ) : #NEWLINE# #INDENT# fname = testfile ( ) #NEWLINE# if ( self . cls == similarities . Similarity ) : #NEWLINE# #INDENT# index = self . cls ( None , corpus , num_features = len ( dictionary ) , shardsize = 5 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# index = self . cls ( corpus , num_features = len ( dictionary ) ) #NEWLINE# #UNINDENT# index . save ( fname , sep_limit = 0 ) #NEWLINE# index2 = self . cls . load ( fname , mmap = 'r' ) #NEWLINE# if ( self . cls == similarities . Similarity ) : #NEWLINE# #INDENT# self . assertTrue ( ( len ( index . shards ) == len ( index2 . shards ) ) ) #NEWLINE# index . destroy ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( index2 , similarities . SparseMatrixSimilarity ) : #NEWLINE# #INDENT# index . index = index . index . todense ( ) #NEWLINE# index2 . index = index2 . index . todense ( ) #NEWLINE# #UNINDENT# self . assertTrue ( numpy . allclose ( index . index , index2 . index ) ) #NEWLINE# self . assertEqual ( index . num_best , index2 . num_best )