示例#1
0
def should_raise_exception(param, value):
    try:
        config.set(param, value)
    except:
        assert True
    else:
        assert False
示例#2
0
def test_pebl(numvars, numsamples, greedy_iters, cachesize):
    print "Testing with #vars=%d, #samples=%d, iters=%d, cachesize=%d" % (
    numvars, numsamples, greedy_iters, cachesize)

    config.set('localscore_cache.maxsize', cachesize)
    d = data.Dataset(N.random.rand(numsamples, numvars))
    d.discretize()
    g = greedy.GreedyLearner(d, max_iterations=greedy_iters)
    g.run()
    return g
示例#3
0
    def test_configobj1(self):
        expected = \
"""[test]
param1 = foo
param0 = foo

[test1]
param1 = 5

"""

        config.IntParameter('test1.param1', 'a param', default=5)
        config.set('test.param1', 'foo')
        params = [config._parameters.get(x) for x in ('test.param0', 'test.param1', 'test1.param1')]

        tmpfile = NamedTemporaryFile(prefix="pebl.test")
        config.configobj(params).write(tmpfile)
        
        tmpfile.file.seek(0)
        actual = tmpfile.read()
        assert actual == expected
示例#4
0
 def test_set8(self):
     config.set('test.param1', 'foo')
     config.set('test.param1', 'bar')
     should_raise_exception('test.param1', 'foobar')
示例#5
0
 def test_set7(self):
     config.set('test.param7', 1.50)
     config.set('test.param7', "1.50")
     config.set('test.param7', "1.5e0")
     assert config.get('test.param7') == 1.5
     assert isinstance(config.get('test.param7'), float)
示例#6
0
 def test_set4(self):
     config.set('test.param5', 50) # no exception
     should_raise_exception('test.param5', 5)
     assert config.get('test.param5') == 50
示例#7
0
 def test_set3(self):
     config.set('test.param4', 150) # no exception
     should_raise_exception('test.param4', 50)
示例#8
0
 def test_get4(self):
     config.set('test.param2', "10")
     assert isinstance(config.get('test.param2'), int)
     assert config.get('test.param2') == 10
示例#9
0
 def setUp(self):
     config.set("evaluator.missingdata_evaluator", "exact")
     self.data = data.fromfile(testfile("testdata13.txt")).subset(samples=range(5))
     self.learner = greedy.GreedyLearner(self.data, max_iterations=10)
示例#10
0
 def setUp(self):
     config.set("evaluator.missingdata_evaluator", self.missing_evaluator)
     self.data = data.fromfile(testfile("testdata13.txt"))
     self.learner = self.learnertype(self.data)