#NEWLINE# def test_message_to_child( self ) : #NEWLINE# #INDENT# '\n        Test the message to child of Gate node.\n        ' #NEWLINE# Z = 2 #NEWLINE# X = GaussianARD ( [ 1 , 2 , 3 ] , 1 , shape = ( ) , plates = ( 3 , ) ) #NEWLINE# Y = Gate ( Z , X ) #NEWLINE# u = Y . _message_to_child ( ) #NEWLINE# self . assertEqual ( len ( u ) , 2 ) #NEWLINE# self . assertAllClose ( u [ 0 ] , 3 ) #NEWLINE# self . assertAllClose ( u [ 1 ] , ( ( 3 ** 2 ) + 1 ) ) #NEWLINE# Z = 2 #NEWLINE# X = [ 1 , 2 , 3 ] #NEWLINE# Y = Gate ( Z , X , moments = GaussianMoments ( ( ) ) ) #NEWLINE# u = Y . _message_to_child ( ) #NEWLINE# self . assertEqual ( len ( u ) , 2 ) #NEWLINE# self . assertAllClose ( u [ 0 ] , 3 ) #NEWLINE# self . assertAllClose ( u [ 1 ] , ( 3 ** 2 ) ) #NEWLINE# Z = Categorical ( [ 0.2 , 0.3 , 0.5 ] ) #NEWLINE# X = GaussianARD ( [ 1 , 2 , 3 ] , 1 , shape = ( ) , plates = ( 3 , ) ) #NEWLINE# Y = Gate ( Z , u ) #NEWLINE# u = Y . _message_to_child ( ) #NEWLINE# self . assertAllClose ( u [ 0 ] , ( ( ( 0.2 * 1 ) + ( 0.3 * 2 ) ) + ( 0.5 * 3 ) ) ) #NEWLINE# self . assertAllClose ( u [ 1 ] , ( ( ( 0.2 * 2 ) + ( 0.3 * 5 ) ) + ( 0.5 * 10 ) ) ) #NEWLINE# Z = [ 2 , 0 ] #NEWLINE# X = GaussianARD ( [ 1 , 2 , 3 ] , 1 , shape = ( ) , plates = ( 3 , ) ) #NEWLINE# Y = Gate ( Z , X ) #NEWLINE# u = Y . _message_to_child ( ) #NEWLINE# self . assertAllClose ( u [ 0 ] , [ 3 , 1 ] ) #NEWLINE# self . assertAllClose ( u [ 1 ] , [ 10 , 2 ] ) #NEWLINE# Z = 2 #NEWLINE# X = GaussianARD ( [ 1 , 2 , 3 ] , 1 , shape = ( ) , plates = ( 4 , 3 ) ) #NEWLINE# Y = Gate ( Z , X ) #NEWLINE# u = Y . _message_to_child ( ) #NEWLINE# self . assertAllClose ( ( np . ones ( 4 ) * u [ 0 ] ) , ( np . ones ( 4 ) * 3 ) ) #NEWLINE# self . assertAllClose ( ( np . ones ( 4 ) * u [ 1 ] ) , ( np . ones ( 4 ) * 10 ) ) #NEWLINE# Z = 2 #NEWLINE# X = GaussianARD ( [ [ 1 ] , [ 2 ] , [ 3 ] ] , 1 , shape = ( ) , plates = ( 3 , 4 ) ) #NEWLINE# Y = Gate ( Z , X , gated_plate = ( - 2 ) ) #NEWLINE# u = Y . _message_to_child ( ) #NEWLINE# self . assertAllClose ( ( np . ones ( 4 ) * u [ 0 ] ) , ( np . ones ( 4 ) * 3 ) ) #NEWLINE# self . assertAllClose ( ( np . ones ( 4 ) * u [ 1 ] ) , ( np . ones ( 4 ) * 10 ) ) #NEWLINE# Z = 2 #NEWLINE# X = GaussianARD ( [ ( 1 * np . ones ( 4 ) ) , ( 2 * np . ones ( 4 ) ) , ( 3 * np . ones ( 4 ) ) ] , 1 , shape = ( 4 , ) , plates = ( 3 , ) ) #NEWLINE# Y = Gate ( Z , X ) #NEWLINE# u = Y . _message_to_child ( ) #NEWLINE# self . assertAllClose ( u [ 0 ] , ( 3 * np . ones ( 4 ) ) ) #NEWLINE# self . assertAllClose ( u [ 1 ] , ( ( 9 * np . ones ( ( 4 , 4 ) ) ) + ( 1 * np . identity ( 4 ) ) ) ) #NEWLINE# Z = 2 #NEWLINE# X = GaussianARD ( 1 , 1 , shape = ( ) , plates = ( 3 , ) ) #NEWLINE# Y = Gate ( Z , X ) #NEWLINE# u = Y . _message_to_child ( ) #NEWLINE# self . assertEqual ( len ( u ) , 2 ) #NEWLINE# self . assertAllClose ( u [ 0 ] , 1 ) #NEWLINE# self . assertAllClose ( u [ 1 ] , ( ( 1 ** 2 ) + 1 ) ) #NEWLINE# pass