def test_check_input_dict(): obs = {'guest' : 'A'} _check_input(obs, monty_network) obs = {'guest' : 'NaN'} assert_raises(ValueError, _check_input, obs, monty_network) obs = {'guest' : None} assert_raises(ValueError, _check_input, obs, monty_network) obs = {'guest' : numpy.nan} assert_raises(ValueError, _check_input, obs, monty_network) obs = {'guest' : 'NaN', 'prize' : 'B'} assert_raises(ValueError, _check_input, obs, monty_network) obs = {'guest' : 'A', 'prize' : 'C'} _check_input(obs, monty_network) obs = {'guest' : 'A', 'prize' : 'C', 'monty' : 'C'} _check_input(obs, monty_network) obs = {'guest' : DiscreteDistribution({'A' : 0.25, 'B' : 0.25, 'C' : 0.50})} _check_input(obs, monty_network) obs = {'hello' : 'A', 'prize' : 'B'} assert_raises(ValueError, _check_input, obs, monty_network)
def test_check_input_dict(): obs = {'guest' : 'A'} _check_input(obs, monty_network) obs = {'guest' : 'NaN'} assert_raises(ValueError, _check_input, obs, monty_network) obs = {'guest' : None} assert_raises(ValueError, _check_input, obs, monty_network) obs = {'guest' : numpy.nan} assert_raises(ValueError, _check_input, obs, monty_network) obs = {'guest' : 'NaN', 'prize' : 'B'} assert_raises(ValueError, _check_input, obs, monty_network) obs = {'guest' : 'A', 'prize' : 'C'} _check_input(obs, monty_network) obs = {'guest' : 'A', 'prize' : 'C', 'monty' : 'C'} _check_input(obs, monty_network) obs = {'guest' : DiscreteDistribution({'A' : 0.25, 'B' : 0.25, 'C' : 0.50})} _check_input(obs, monty_network) obs = {'hello' : 'A', 'prize' : 'B'} assert_raises(ValueError, _check_input, obs, monty_network)
def test_check_input_list_of_lists(): obs = ['A', None, None] _check_input([obs], monty_network) obs = ['A', numpy.nan, numpy.nan] _check_input([obs], monty_network) obs = numpy.array(['A', None, None]) _check_input([obs], monty_network) obs = numpy.array(['A', numpy.nan, numpy.nan]) _check_input([obs], monty_network) obs = numpy.array(['A', 'B', 'C']) _check_input([obs], monty_network) obs = numpy.array(['NaN', numpy.nan, numpy.nan]) assert_raises(ValueError, _check_input, [obs], monty_network) obs = numpy.array(['A', 'B', 'D']) assert_raises(ValueError, _check_input, [obs], monty_network) obs = ['A'] assert_raises(ValueError, _check_input, [obs], monty_network) obs = ['A', 'C', 'E', 'F'] assert_raises(ValueError, _check_input, [obs], monty_network) d = DiscreteDistribution({'A': 0.25, 'B': 0.25, 'C': 0.25}) obs = [d, None, None] _check_input([obs], monty_network) e = DiscreteDistribution({'A': 0.25, 'B': 0.25, 'D': 0.25}) obs = [e, None, None] assert_raises(ValueError, _check_input, [obs], monty_network) obs = [['A', None, None], ['A', numpy.nan, numpy.nan], ['A', 'B', 'C'], ['A', None, 'C'], [None, 'B', 'C'], [d, None, None]] _check_input(obs, monty_network) obs.append([e, None, None]) assert_raises(ValueError, _check_input, obs, monty_network)
def test_check_input_list_of_lists(): obs = ['A', None, None] _check_input([obs], monty_network) obs = ['A', numpy.nan, numpy.nan] _check_input([obs], monty_network) obs = numpy.array(['A', None, None]) _check_input([obs], monty_network) obs = numpy.array(['A', numpy.nan, numpy.nan]) _check_input([obs], monty_network) obs = numpy.array(['A', 'B', 'C']) _check_input([obs], monty_network) obs = numpy.array(['NaN', numpy.nan, numpy.nan]) assert_raises(ValueError, _check_input, [obs], monty_network) obs = numpy.array(['A', 'B', 'D']) assert_raises(ValueError, _check_input, [obs], monty_network) obs = ['A'] assert_raises(ValueError, _check_input, [obs], monty_network) obs = ['A', 'C', 'E', 'F'] assert_raises(ValueError, _check_input, [obs], monty_network) d = DiscreteDistribution({'A': 0.25, 'B': 0.25, 'C': 0.25}) obs = [d, None, None] _check_input([obs], monty_network) e = DiscreteDistribution({'A': 0.25, 'B': 0.25, 'D': 0.25}) obs = [e, None, None] assert_raises(ValueError, _check_input, [obs], monty_network) obs = [['A', None, None], ['A', numpy.nan, numpy.nan], ['A', 'B', 'C'], ['A', None, 'C'], [None, 'B', 'C'], [d, None, None]] _check_input(obs, monty_network) obs.append([e, None, None]) assert_raises(ValueError, _check_input, obs, monty_network)