def test_adding_examples(self): """Make sure test examples are added properly. """ manager = ExampleManager() # figure out the expected number of examples in each category expected_train = manager.training_percent * self.num_examples expected_validation = manager.validation_percent * self.num_examples expected_test = self.num_examples - expected_train \ - expected_validation manager.add_examples(self.examples) for expect, actual in [(expected_train, len(manager.train_examples)), (expected_validation, len(manager.validation_examples)), (expected_test, len(manager.test_examples))]: wrong_percent = abs(expect - actual) / self.num_examples assert wrong_percent < .1, \ "Deviation in how examples were added, expect %s, got %s" \ % (expect, actual)
def test_partioning_examples(self): """Test that we can change how to partition the test examples. """ manager = ExampleManager(0, 0) manager.add_examples(self.examples) assert len(manager.test_examples) == self.num_examples, \ "Did not partition correctly to test_examples." manager = ExampleManager(1.0, 0) manager.add_examples(self.examples) assert len(manager.train_examples) == self.num_examples, \ "Did not partition correctly to train_examples." manager = ExampleManager(0, 1.0) manager.add_examples(self.examples) assert len(manager.validation_examples) == self.num_examples, \ "Did not partition correctly to validation_examples."