#NEWLINE# def test_consistency_cpu_parallel( ) : #NEWLINE# #INDENT# "\n    Verify that the random numbers generated by mrg_uniform, in parallel,\n    are the same as the reference (Java) implementation by L'Ecuyer et al.\n\n    " #NEWLINE# seed = 12345 #NEWLINE# n_samples = 5 #NEWLINE# n_streams = 12 #NEWLINE# n_substreams = 7 #NEWLINE# samples = [ ] #NEWLINE# curr_rstate = numpy . array ( ( [ seed ] * 6 ) , dtype = 'int32' ) #NEWLINE# for i in range ( n_streams ) : #NEWLINE# #INDENT# stream_samples = [ ] #NEWLINE# rstate = [ curr_rstate . copy ( ) ] #NEWLINE# for j in range ( 1 , n_substreams ) : #NEWLINE# #INDENT# rstate . append ( rng_mrg . ff_2p72 ( rstate [ ( - 1 ) ] ) ) #NEWLINE# #UNINDENT# rstate = numpy . asarray ( rstate ) #NEWLINE# rstate = theano . shared ( rstate ) #NEWLINE# ( new_rstate , sample ) = rng_mrg . mrg_uniform . new ( rstate , ndim = None , dtype = config . floatX , size = ( n_substreams , ) ) #NEWLINE# sample . rstate = rstate #NEWLINE# sample . update = ( rstate , new_rstate ) #NEWLINE# rstate . default_update = new_rstate #NEWLINE# f = theano . function ( [ ] , sample ) #NEWLINE# for k in range ( n_samples ) : #NEWLINE# #INDENT# s = f ( ) #NEWLINE# stream_samples . append ( s ) #NEWLINE# #UNINDENT# samples . append ( numpy . array ( stream_samples ) . T . flatten ( ) ) #NEWLINE# curr_rstate = rng_mrg . ff_2p134 ( curr_rstate ) #NEWLINE# #UNINDENT# samples = numpy . array ( samples ) . flatten ( ) #NEWLINE# assert numpy . allclose ( samples , java_samples )