<s> import pytest <EOL> from itertools import product as xproduct <EOL> from bayesian . gaussian import * <EOL> def pytest_funcarg__means_vector_a ( request ) : <EOL> m = MeansVector ( [ [ <NUM_LIT:0> ] , [ <NUM_LIT:1> ] , [ <NUM_LIT:2> ] ] , names = ( '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ) ) <EOL> return m <EOL> def pytest_funcarg__means_vector_b ( request ) : <EOL> m = MeansVector ( [ [ <NUM_LIT:0> ] , [ <NUM_LIT:1> ] , [ <NUM_LIT:2> ] ] , names = ( '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ) ) <EOL> return m <EOL> def pytest_funcarg__means_vector_c ( request ) : <EOL> m = MeansVector ( [ [ <NUM_LIT:0> ] , [ <NUM_LIT:1> ] , [ <NUM_LIT:2> ] ] , names = ( '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:d>' ) ) <EOL> return m <EOL> def pytest_funcarg__means_vector_d ( request ) : <EOL> m = MeansVector ( [ [ <NUM_LIT:0> ] , [ <NUM_LIT:1> ] , [ <NUM_LIT:3> ] ] , names = ( '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ) ) <EOL> return m <EOL> class TestGaussian ( ) : <EOL> def test_joint_to_conditional_1 ( self ) : <EOL> '''<STR_LIT>''' <EOL> mu_x = MeansVector ( [ [ <NUM_LIT:1> ] ] ) <EOL> mu_y = MeansVector ( [ [ - <NUM_LIT> ] ] ) <EOL> sigma_xx = CovarianceMatrix ( [ [ <NUM_LIT:4> ] ] ) <EOL> sigma_xy = CovarianceMatrix ( [ [ <NUM_LIT:2> ] ] ) <EOL> sigma_yx = CovarianceMatrix ( [ [ <NUM_LIT:2> ] ] ) <EOL> sigma_yy = CovarianceMatrix ( [ [ <NUM_LIT:5> ] ] ) <EOL> beta_0 , beta , sigma = joint_to_conditional ( <EOL> mu_x , mu_y , sigma_xx , sigma_xy , sigma_yx , sigma_yy ) <EOL> assert beta_0 == - <NUM_LIT:5> <EOL> assert beta == Matrix ( [ [ <NUM_LIT:0.5> ] ] ) <EOL> assert sigma == Matrix ( [ [ <NUM_LIT:4> ] ] ) <EOL> def test_joint_to_conditional_2 ( self ) : <EOL> mu_x = MeansVector ( [ [ - <NUM_LIT> ] ] ) <EOL> mu_y = MeansVector ( [ [ <NUM_LIT> ] ] ) <EOL> sigma_xx = CovarianceMatrix ( [ [ <NUM_LIT:5> ] ] ) <EOL> sigma_xy = CovarianceMatrix ( [ [ - <NUM_LIT:5> ] ] ) <EOL> sigma_yx = CovarianceMatrix ( [ [ - <NUM_LIT:5> ] ] ) <EOL> sigma_yy = CovarianceMatrix ( [ [ <NUM_LIT:8> ] ] ) <EOL> beta_0 , beta , sigma = joint_to_conditional ( <EOL> mu_x , mu_y , sigma_xx , sigma_xy , sigma_yx , sigma_yy ) <EOL> assert beta_0 == <NUM_LIT:4> <EOL> assert beta == Matrix ( [ [ - <NUM_LIT:1> ] ] ) <EOL> assert sigma == Matrix ( [ [ <NUM_LIT:3> ] ] ) <EOL> def test_joint_to_conditional_3 ( self ) : <EOL> mu_x = MeansVector ( [ [ <NUM_LIT:3> ] ] ) <EOL> mu_y = MeansVector ( [ [ <NUM_LIT:4> ] ] ) <EOL> sigma_xx = CovarianceMatrix ( [ [ <NUM_LIT:4> ] ] ) <EOL> sigma_xy = CovarianceMatrix ( [ [ <NUM_LIT:4> ] ] ) <EOL> sigma_yx = CovarianceMatrix ( [ [ <NUM_LIT:4> ] ] ) <EOL> sigma_yy = CovarianceMatrix ( [ [ <NUM_LIT:5> ] ] ) <EOL> beta_0 , beta , sigma = joint_to_conditional ( <EOL> mu_x , mu_y , sigma_xx , sigma_xy , sigma_yx , sigma_yy ) <EOL> assert beta_0 == <NUM_LIT:1> <EOL> assert beta == Matrix ( [ [ <NUM_LIT:1> ] ] ) <EOL> assert sigma == Matrix ( [ [ <NUM_LIT:1> ] ] ) <EOL> def test_joint_to_conditional_4 ( self ) : <EOL> mu_x = MeansVector ( [ [ <NUM_LIT:3> ] ] ) <EOL> mu_y = MeansVector ( [ [ <NUM_LIT:9> ] ] ) <EOL> sigma_xx = CovarianceMatrix ( [ [ <NUM_LIT:4> ] ] ) <EOL> sigma_xy = CovarianceMatrix ( [ [ <NUM_LIT:8> ] ] ) <EOL> sigma_yx = CovarianceMatrix ( [ [ <NUM_LIT:8> ] ] ) <EOL> sigma_yy = CovarianceMatrix ( [ [ <NUM_LIT:20> ] ] ) <EOL> beta_0 , beta , sigma = joint_to_conditional ( <EOL> mu_x , mu_y , sigma_xx , sigma_xy , sigma_yx , sigma_yy ) <EOL> assert beta_0 == <NUM_LIT:3> <EOL> assert beta == Matrix ( [ [ <NUM_LIT:2> ] ] ) <EOL> assert sigma == Matrix ( [ [ <NUM_LIT:4> ] ] ) <EOL> def test_joint_to_conditional_5 ( self ) : <EOL> mu_x = MeansVector ( [ <EOL> [ <NUM_LIT:4> ] , <EOL> [ <NUM_LIT:9> ] ] ) <EOL> mu_y = MeansVector ( [ [ <NUM_LIT> ] ] ) <EOL> sigma_xx = CovarianceMatrix ( [ <EOL> [ <NUM_LIT:5> , <NUM_LIT:8> ] , <EOL> [ <NUM_LIT:8> , <NUM_LIT:20> ] ] ) <EOL> sigma_xy = CovarianceMatrix ( [ <EOL> [ <NUM_LIT> ] , <EOL> [ <NUM_LIT> ] ] ) <EOL> sigma_yx = CovarianceMatrix ( [ <EOL> [ <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> sigma_yy = CovarianceMatrix ( [ [ <NUM_LIT> ] ] ) <EOL> beta_0 , beta , sigma = joint_to_conditional ( <EOL> mu_x , mu_y , sigma_xx , sigma_xy , sigma_yx , sigma_yy ) <EOL> assert beta_0 == <NUM_LIT:1> <EOL> assert beta == Matrix ( [ [ <NUM_LIT:1> , <NUM_LIT:1> ] ] ) <EOL> assert sigma == Matrix ( [ [ <NUM_LIT:1> ] ] ) <EOL> def test_conditional_to_joint_1 ( self ) : <EOL> mu_x = MeansVector ( [ [ <NUM_LIT:1> ] ] ) <EOL> sigma_x = CovarianceMatrix ( [ [ <NUM_LIT:4> ] ] ) <EOL> beta_0 = - <NUM_LIT:5> <EOL> beta = MeansVector ( [ [ <NUM_LIT:0.5> ] ] ) <EOL> sigma_c = <NUM_LIT:4> <EOL> mu , sigma = conditional_to_joint ( <EOL> mu_x , sigma_x , beta_0 , beta , sigma_c ) <EOL> assert mu == MeansVector ( [ <EOL> [ <NUM_LIT:1> ] , <EOL> [ - <NUM_LIT> ] ] ) <EOL> assert sigma == CovarianceMatrix ( [ <EOL> [ <NUM_LIT:4> , <NUM_LIT:2> ] , <EOL> [ <NUM_LIT:2> , <NUM_LIT:5> ] ] ) <EOL> def test_conditional_to_joint_2 ( self ) : <EOL> mu_x = MeansVector ( [ <EOL> [ <NUM_LIT:1> ] , <EOL> [ - <NUM_LIT> ] ] ) <EOL> sigma_x = CovarianceMatrix ( [ <EOL> [ <NUM_LIT:4> , <NUM_LIT:2> ] , <EOL> [ <NUM_LIT:2> , <NUM_LIT:5> ] ] ) <EOL> beta_0 = <NUM_LIT:4> <EOL> beta = MeansVector ( [ <EOL> [ <NUM_LIT:0> ] , <EOL> [ - <NUM_LIT:1> ] ] ) <EOL> sigma_c = <NUM_LIT:3> <EOL> mu , sigma = conditional_to_joint ( <EOL> mu_x , sigma_x , beta_0 , beta , sigma_c ) <EOL> assert mu == MeansVector ( [ <EOL> [ <NUM_LIT:1> ] , <EOL> [ - <NUM_LIT> ] , <EOL> [ <NUM_LIT> ] ] ) <EOL> assert sigma == CovarianceMatrix ( [ <EOL> [ <NUM_LIT:4> , <NUM_LIT:2> , - <NUM_LIT:2> ] , <EOL> [ <NUM_LIT:2> , <NUM_LIT:5> , - <NUM_LIT:5> ] , <EOL> [ - <NUM_LIT:2> , - <NUM_LIT:5> , <NUM_LIT:8> ] ] ) <EOL> def test_conditional_to_joint_3 ( self ) : <EOL> mu_x = MeansVector ( [ <EOL> [ <NUM_LIT:3> ] ] ) <EOL> sigma_x = CovarianceMatrix ( [ <EOL> [ <NUM_LIT:4> ] ] ) <EOL> beta_0 = <NUM_LIT:1> <EOL> beta = MeansVector ( [ <EOL> [ <NUM_LIT:1> ] ] ) <EOL> sigma_c = <NUM_LIT:1> <EOL> mu , sigma = conditional_to_joint ( <EOL> mu_x , sigma_x , beta_0 , beta , sigma_c ) <EOL> assert mu == MeansVector ( [ <EOL> [ <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:4> ] ] ) <EOL> assert sigma == CovarianceMatrix ( [ <EOL> [ <NUM_LIT:4> , <NUM_LIT:4> ] , <EOL> [ <NUM_LIT:4> , <NUM_LIT:5> ] ] ) <EOL> def test_conditional_to_joint_4 ( self ) : <EOL> mu_x = MeansVector ( [ <EOL> [ <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:4> ] ] ) <EOL> sigma_x = CovarianceMatrix ( [ <EOL> [ <NUM_LIT:4> , <NUM_LIT:4> ] , <EOL> [ <NUM_LIT:4> , <NUM_LIT:5> ] ] ) <EOL> beta_0 = <NUM_LIT:3> <EOL> beta = MeansVector ( [ <EOL> [ <NUM_LIT:2> ] , <EOL> [ <NUM_LIT:0> ] , <EOL> ] ) <EOL> sigma_c = <NUM_LIT:4> <EOL> mu , sigma = conditional_to_joint ( <EOL> mu_x , sigma_x , beta_0 , beta , sigma_c ) <EOL> assert mu == MeansVector ( [ <EOL> [ <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:4> ] , <EOL> [ <NUM_LIT:9> ] ] ) <EOL> assert sigma == CovarianceMatrix ( [ <EOL> [ <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:8> ] , <EOL> [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:8> ] , <EOL> [ <NUM_LIT:8> , <NUM_LIT:8> , <NUM_LIT:20> ] ] ) <EOL> def test_conditional_to_joint_5 ( self ) : <EOL> mu_x = MeansVector ( [ <EOL> [ <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:4> ] , <EOL> [ <NUM_LIT:9> ] ] ) <EOL> sigma_x = CovarianceMatrix ( [ <EOL> [ <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:8> ] , <EOL> [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:8> ] , <EOL> [ <NUM_LIT:8> , <NUM_LIT:8> , <NUM_LIT:20> ] ] ) <EOL> beta_0 = <NUM_LIT:1> <EOL> beta = MeansVector ( [ <EOL> [ <NUM_LIT:0> ] , <EOL> [ <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:1> ] ] ) <EOL> sigma_c = <NUM_LIT:1> <EOL> mu , sigma = conditional_to_joint ( <EOL> mu_x , sigma_x , beta_0 , beta , sigma_c ) <EOL> assert mu == MeansVector ( [ <EOL> [ <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:4> ] , <EOL> [ <NUM_LIT:9> ] , <EOL> [ <NUM_LIT> ] ] ) <EOL> assert sigma == CovarianceMatrix ( [ <EOL> [ <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:8> , <NUM_LIT:12> ] , <EOL> [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:8> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:8> , <NUM_LIT:8> , <NUM_LIT:20> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> mu_x = MeansVector ( [ <EOL> [ <NUM_LIT:3> ] ] ) <EOL> sigma_x = CovarianceMatrix ( [ <EOL> [ <NUM_LIT:4> ] ] ) <EOL> beta_0 = <NUM_LIT:5> <EOL> beta = MeansVector ( [ [ <NUM_LIT:0> ] ] ) <EOL> sigma_c = <NUM_LIT:1> <EOL> mu , sigma = conditional_to_joint ( <EOL> mu_x , sigma_x , beta_0 , beta , sigma_c ) <EOL> assert mu == MeansVector ( [ [ <NUM_LIT:3> ] , [ <NUM_LIT:5> ] ] ) <EOL> assert sigma == CovarianceMatrix ( [ [ <NUM_LIT:4> , <NUM_LIT:0> ] , [ <NUM_LIT:0> , <NUM_LIT:1> ] ] ) <EOL> def test_split ( self ) : <EOL> sigma = CovarianceMatrix ( <EOL> [ <EOL> [ <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:8> , <NUM_LIT:12> ] , <EOL> [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:8> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:8> , <NUM_LIT:8> , <NUM_LIT:20> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] , <EOL> names = [ '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' , '<STR_LIT:d>' ] ) <EOL> sigma_xx , sigma_xy , sigma_yx , sigma_yy = sigma . split ( '<STR_LIT:a>' ) <EOL> print sigma_xx <EOL> print sigma_xy <EOL> for name in [ '<STR_LIT:b>' , '<STR_LIT:c>' , '<STR_LIT:d>' ] : <EOL> assert name in sigma_xx . names <EOL> assert name in sigma_xy . names <EOL> assert name in sigma_yx . names <EOL> assert name not in sigma_yy . names <EOL> assert '<STR_LIT:a>' in sigma_yy . names <EOL> assert '<STR_LIT:a>' not in sigma_xx . names <EOL> assert '<STR_LIT:a>' not in sigma_xy . names <EOL> assert '<STR_LIT:a>' not in sigma_yx . names <EOL> for row , col in xproduct ( [ '<STR_LIT:b>' , '<STR_LIT:c>' , '<STR_LIT:d>' ] , [ '<STR_LIT:b>' , '<STR_LIT:c>' , '<STR_LIT:d>' ] ) : <EOL> assert sigma_xx [ row , col ] == sigma [ row , col ] <EOL> sigma_xx , sigma_xy , sigma_yx , sigma_yy = sigma_xx . split ( '<STR_LIT:d>' ) <EOL> mu_x = MeansVector ( [ <EOL> [ <NUM_LIT:4> ] , <EOL> [ <NUM_LIT:9> ] ] ) <EOL> mu_y = MeansVector ( [ <EOL> [ <NUM_LIT> ] ] ) <EOL> beta_0 , beta , sigma = joint_to_conditional ( <EOL> mu_x , mu_y , sigma_xx , sigma_xy , sigma_yx , sigma_yy ) <EOL> assert beta_0 == <NUM_LIT:1> <EOL> assert beta == Matrix ( [ [ <NUM_LIT:1> , <NUM_LIT:1> ] ] ) <EOL> assert sigma == Matrix ( [ [ <NUM_LIT:1> ] ] ) <EOL> def test_means_vector_equality ( <EOL> self , means_vector_a , means_vector_b , <EOL> means_vector_c , means_vector_d ) : <EOL> assert means_vector_a == means_vector_b <EOL> assert means_vector_a != means_vector_c <EOL> assert means_vector_a != means_vector_d </s>
