#NEWLINE# def test_seed_fn( ) : #NEWLINE# #INDENT# test_use_cuda = [ False ] #NEWLINE# if cuda_available : #NEWLINE# #INDENT# test_use_cuda . append ( True ) #NEWLINE# #UNINDENT# idx = tensor . ivector ( ) #NEWLINE# for use_cuda in test_use_cuda : #NEWLINE# #INDENT# if ( ( config . mode == 'FAST_COMPILE' ) and use_cuda ) : #NEWLINE# #INDENT# mode = 'FAST_RUN' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mode = config . mode #NEWLINE# #UNINDENT# for ( new_seed , same ) in [ ( 234 , True ) , ( None , True ) , ( 23 , False ) ] : #NEWLINE# #INDENT# random = MRG_RandomStreams ( 234 , use_cuda = use_cuda ) #NEWLINE# fn1 = theano . function ( [ ] , random . uniform ( ( 2 , 2 ) , dtype = 'float32' ) , mode = mode ) #NEWLINE# fn2 = theano . function ( [ ] , random . uniform ( ( 3 , 3 ) , nstreams = 2 , dtype = 'float32' ) , mode = mode ) #NEWLINE# fn3 = theano . function ( [ idx ] , random . uniform ( idx , nstreams = 3 , ndim = 1 , dtype = 'float32' ) , mode = mode ) #NEWLINE# fn1_val0 = fn1 ( ) #NEWLINE# fn1_val1 = fn1 ( ) #NEWLINE# assert ( not numpy . allclose ( fn1_val0 , fn1_val1 ) ) #NEWLINE# fn2_val0 = fn2 ( ) #NEWLINE# fn2_val1 = fn2 ( ) #NEWLINE# assert ( not numpy . allclose ( fn2_val0 , fn2_val1 ) ) #NEWLINE# fn3_val0 = fn3 ( [ 4 ] ) #NEWLINE# fn3_val1 = fn3 ( [ 4 ] ) #NEWLINE# assert ( not numpy . allclose ( fn3_val0 , fn3_val1 ) ) #NEWLINE# assert ( fn1_val0 . size == 4 ) #NEWLINE# assert ( fn2_val0 . size == 9 ) #NEWLINE# random . seed ( new_seed ) #NEWLINE# fn1_val2 = fn1 ( ) #NEWLINE# fn1_val3 = fn1 ( ) #NEWLINE# fn2_val2 = fn2 ( ) #NEWLINE# fn2_val3 = fn2 ( ) #NEWLINE# fn3_val2 = fn3 ( [ 4 ] ) #NEWLINE# fn3_val3 = fn3 ( [ 4 ] ) #NEWLINE# assert ( numpy . allclose ( fn1_val0 , fn1_val2 ) == same ) #NEWLINE# assert ( numpy . allclose ( fn1_val1 , fn1_val3 ) == same ) #NEWLINE# assert ( numpy . allclose ( fn2_val0 , fn2_val2 ) == same ) #NEWLINE# assert ( numpy . allclose ( fn2_val1 , fn2_val3 ) == same ) #NEWLINE# assert ( numpy . allclose ( fn3_val0 , fn3_val2 ) == same ) #NEWLINE# assert ( numpy . allclose ( fn3_val1 , fn3_val3 ) == same )