def setUp(self): self.mocks = [ MockHypothesis(fitness=0.5), MockHypothesis(fitness=0.6), MockHypothesis(fitness=0.7) ] self.decisioner = Decisioner(self.mocks, training_window=0)
def test_get_guess_training_window(self): """Tests the 'get_guess' method of the decisioner with the training window in place""" # First we know need to create a new decisioner with a new # training window decisioner = Decisioner(self.mocks, training_window=100) # Then we test that we are receiving true while in the window for i in range(100): self.assertTrue(decisioner.get_guess(self.FAKE_VECTOR)) decisioner.update(self.FAKE_VECTOR, self.FAKE_ACTION, self.FAKE_OUTCOME) # Finally now that we've exceeded the window we test that we # are actually getting hypothesis that are chosen self.mocks[0]._fitness = 0.99 self.mocks[0]._next_guess = 'spam' response = decisioner.get_guess(self.FAKE_VECTOR) self.assertEqual('spam', response)
def setUpDecisioner(self, *hypothesis, **kwargs): self.hypothesis = hypothesis self.decisioner = Decisioner(self.hypothesis, **kwargs)