<s> import unittest <EOL> import numpy as np <EOL> import numpy . testing as np_test <EOL> from pgmpy . models import NoisyOrModel <EOL> class TestNoisyOrModelInit ( unittest . TestCase ) : <EOL> def test_init ( self ) : <EOL> model = NoisyOrModel ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ] , [ [ <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:0.1> , <NUM_LIT> ] ] ) <EOL> np_test . assert_array_equal ( model . variables , np . array ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) ) <EOL> np_test . assert_array_equal ( model . cardinality , np . array ( [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ] ) ) <EOL> self . assertListEqual ( model . inhibitor_probability , [ [ <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:0.1> , <NUM_LIT> ] ] ) <EOL> def test_exceptions ( self ) : <EOL> self . assertRaises ( ValueError , NoisyOrModel , np . array ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) , [ <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> ] , [ [ <NUM_LIT:0.1> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:1.0> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT:0.1> ] ] ) <EOL> self . assertRaises ( ValueError , NoisyOrModel , np . array ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) , [ <NUM_LIT:2> , <NUM_LIT:4> ] , [ [ <NUM_LIT:0.1> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> self . assertRaises ( ValueError , NoisyOrModel , np . array ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) , [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:3> ] , [ [ <NUM_LIT:0.1> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0.5> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> self . assertRaises ( ValueError , NoisyOrModel , np . array ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) , [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ] , [ [ <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT:0.5> ] , <EOL> [ <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT> ] ] ) <EOL> self . assertRaises ( ValueError , NoisyOrModel , np . array ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) , [ <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> ] , [ [ <NUM_LIT:0.1> , <NUM_LIT:0.1> ] , <EOL> [ <NUM_LIT:0.1> , <NUM_LIT:0.1> ] ] ) <EOL> class TestNoisyOrModelMethods ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . model = NoisyOrModel ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ] , [ [ <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:0.1> , <NUM_LIT> ] ] ) <EOL> def test_add_variables ( self ) : <EOL> self . model . add_variables ( [ '<STR_LIT>' ] , [ <NUM_LIT:3> ] , [ <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> np_test . assert_array_equal ( self . model . variables , np . array ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) ) <EOL> np_test . assert_array_equal ( self . model . cardinality , np . array ( [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:3> ] ) ) <EOL> self . assertListEqual ( self . model . inhibitor_probability , [ [ <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:0.1> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> self . model . add_variables ( [ '<STR_LIT>' , '<STR_LIT>' ] , [ <NUM_LIT:3> , <NUM_LIT:2> ] , [ [ <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> ] , [ <NUM_LIT:0.5> , <NUM_LIT:0.5> ] ] ) <EOL> np_test . assert_array_equal ( self . model . variables , np . array ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) ) <EOL> np_test . assert_array_equal ( self . model . cardinality , np . array ( [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:2> ] ) ) <EOL> self . assertListEqual ( self . model . inhibitor_probability , [ [ <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:0.1> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:0.5> , <NUM_LIT:0.5> ] ] ) <EOL> def test_del_variables ( self ) : <EOL> self . model . del_variables ( [ '<STR_LIT>' ] ) <EOL> np_test . assert_array_equal ( self . model . variables , np . array ( [ '<STR_LIT>' , '<STR_LIT>' ] ) ) <EOL> np_test . assert_array_equal ( self . model . cardinality , np . array ( [ <NUM_LIT:2> , <NUM_LIT:3> ] ) ) <EOL> self . assertListEqual ( self . model . inhibitor_probability , [ [ <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> def test_del_multiple_variables ( self ) : <EOL> self . model . del_variables ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> np_test . assert_array_equal ( self . model . variables , np . array ( [ '<STR_LIT>' ] ) ) <EOL> np_test . assert_array_equal ( self . model . cardinality , np . array ( [ <NUM_LIT:2> ] ) ) <EOL> self . assertListEqual ( self . model . inhibitor_probability , [ [ <NUM_LIT:0.1> , <NUM_LIT> ] ] ) </s>
