#NEWLINE# def test_randomSeed( self ) : #NEWLINE# #INDENT# from vsm.corpus.util.corpusbuilders import random_corpus #NEWLINE# from vsm.model.ldacgsseq import LdaCgsSeq #NEWLINE# c = random_corpus ( 1000 , 50 , 0 , 20 , context_type = 'document' , metadata = True ) #NEWLINE# m0 = LdaCgsSeq ( c , 'document' , K = 10 ) #NEWLINE# assert ( m0 . seed is not None ) #NEWLINE# orig_seed = m0 . seed #NEWLINE# m1 = LdaCgsSeq ( c , 'document' , K = 10 , seed = orig_seed ) #NEWLINE# assert ( m0 . seed == m1 . seed ) #NEWLINE# m0 . train ( n_iterations = 50 , verbose = 0 ) #NEWLINE# m1 . train ( n_iterations = 50 , verbose = 0 ) #NEWLINE# assert ( m0 . seed == orig_seed ) #NEWLINE# assert ( m1 . seed == orig_seed ) #NEWLINE# assert ( m0 . _mtrand_state [ 0 ] == 'MT19937' ) #NEWLINE# assert ( m1 . _mtrand_state [ 0 ] == 'MT19937' ) #NEWLINE# assert ( m0 . _mtrand_state [ 1 ] == m1 . _mtrand_state [ 1 ] ) . all ( ) #NEWLINE# assert ( m0 . _mtrand_state [ 2 : ] == m1 . _mtrand_state [ 2 : ] ) #NEWLINE# self . assertTrue ( ( m0 . context_type == m1 . context_type ) ) #NEWLINE# self . assertTrue ( ( m0 . K == m1 . K ) ) #NEWLINE# self . assertTrue ( ( m0 . alpha == m1 . alpha ) . all ( ) ) #NEWLINE# self . assertTrue ( ( m0 . beta == m1 . beta ) . all ( ) ) #NEWLINE# self . assertTrue ( ( m0 . log_probs == m1 . log_probs ) ) #NEWLINE# for i in xrange ( max ( len ( m0 . corpus ) , len ( m1 . corpus ) ) ) : #NEWLINE# #INDENT# self . assertTrue ( ( m0 . corpus [ i ] . all ( ) == m1 . corpus [ i ] . all ( ) ) ) #NEWLINE# #UNINDENT# self . assertTrue ( ( m0 . V == m1 . V ) ) #NEWLINE# self . assertTrue ( ( m0 . iteration == m1 . iteration ) ) #NEWLINE# for i in xrange ( max ( len ( m0 . Z ) , len ( m1 . Z ) ) ) : #NEWLINE# #INDENT# self . assertTrue ( ( m0 . Z [ i ] . all ( ) == m1 . Z [ i ] . all ( ) ) ) #NEWLINE# #UNINDENT# self . assertTrue ( ( m0 . top_doc . all ( ) == m1 . top_doc . all ( ) ) ) #NEWLINE# self . assertTrue ( ( m0 . word_top . all ( ) == m1 . word_top . all ( ) ) ) #NEWLINE# self . assertTrue ( ( m0 . inv_top_sums . all ( ) == m1 . inv_top_sums . all ( ) ) )