#NEWLINE# def test_get_cardinality_check_cardinality( self ) : #NEWLINE# #INDENT# self . graph . add_edges_from ( [ ( 'a' , 'b' ) , ( 'b' , 'c' ) , ( 'c' , 'd' ) , ( 'd' , 'a' ) ] ) #NEWLINE# phi1 = Factor ( [ 'a' , 'b' ] , [ 1 , 2 ] , np . random . rand ( 2 ) ) #NEWLINE# self . graph . add_factors ( phi1 ) #NEWLINE# self . assertRaises ( ValueError , self . graph . get_cardinality , check_cardinality = True ) #NEWLINE# phi2 = Factor ( [ 'a' , 'c' ] , [ 1 , 2 ] , np . random . rand ( 2 ) ) #NEWLINE# self . graph . add_factors ( phi2 ) #NEWLINE# self . assertRaises ( ValueError , self . graph . get_cardinality , check_cardinality = True ) #NEWLINE# phi3 = Factor ( [ 'c' , 'd' ] , [ 2 , 2 ] , np . random . rand ( 4 ) ) #NEWLINE# self . graph . add_factors ( phi3 ) #NEWLINE# self . assertDictEqual ( self . graph . get_cardinality ( check_cardinality = True ) , { #NEWLINE# #INDENT# 'd' : 2 , #NEWLINE# 'c' : 2 , #NEWLINE# 'b' : 2 , #NEWLINE# 'a' : 1 , #NEWLINE# #UNINDENT# } )