#NEWLINE# def test_call_weighted_choices( self ) : #NEWLINE# #INDENT# g = build_graph ( 'ab bc cb bb cc' ) #NEWLINE# g . E [ 'bb' ] = Thing ( ( 'bb' , 'bb' , 'b' , 'b' , '25%' ) ) #NEWLINE# g . V [ 'b' ] . outgoing [ 0 ] = g . E [ 'bb' ] #NEWLINE# p = self . thiscls ( ) #NEWLINE# p . rng = r = rng ( [ 0 , 0.26 , 0 , 0.24 , 1 , 0 ] ) #NEWLINE# plan = zip ( p ( g , EhmNo ( ) , 'a' , 'context' ) , range ( 10 ) ) #NEWLINE# l = [ ( g . E [ 'ab' ] , 0 ) , ( g . V [ 'b' ] , 1 ) , ( g . E [ 'bc' ] , 2 ) , ( g . V [ 'c' ] , 3 ) , ( g . E [ 'cb' ] , 4 ) , ( g . V [ 'b' ] , 5 ) , ( g . E [ 'bb' ] , 6 ) , ( g . V [ 'b' ] , 7 ) , ( g . E [ 'bc' ] , 8 ) , ( g . V [ 'c' ] , 9 ) ] #NEWLINE# if ( plan != l ) : #NEWLINE# #INDENT# for i in range ( min ( len ( plan ) , len ( l ) ) ) : #NEWLINE# #INDENT# print ( i , '=!' [ ( plan [ i ] != l [ i ] ) ] , plan [ i ] , l [ i ] ) #NEWLINE# #UNINDENT# #UNINDENT# self . assertEqual ( plan , l ) #NEWLINE# calls = [ ( 'choice' , [ g . E [ 'ab' ] ] ) , ( 'uniform' , 0.0 , 1.0 ) , ( 'choice' , [ g . E [ 'cb' ] , g . E [ 'cc' ] ] ) , ( 'uniform' , 0.0 , 1.0 ) , ( 'uniform' , 0.0 , 1.0 ) , ( 'choice' , [ g . E [ 'cb' ] , g . E [ 'cc' ] ] ) ] #NEWLINE# if ( r . calls != calls ) : #NEWLINE# #INDENT# for i in range ( min ( len ( r . calls ) , len ( calls ) ) ) : #NEWLINE# #INDENT# print ( g , '=!' [ ( r . calls [ i ] != calls [ i ] ) ] , r . calls [ i ] , calls [ i ] ) #NEWLINE# #UNINDENT# #UNINDENT# self . assertEqual ( p . rng . calls , calls )