def testStandardSplit(self): splitter = data_split.StandardSplit() self.assertSequenceEqual(splitter.split(xrange(10)), ([0, 1, 2, 3, 4, 5, 6, 7], [8, 9])) self.assertSequenceEqual(splitter.split(xrange(11)), ([0, 1, 2, 3, 4, 5, 6, 7], [8, 9, 10])) splitter = data_split.StandardSplit(0.7) self.assertSequenceEqual(splitter.split(xrange(10)), ([0, 1, 2, 3, 4, 5, 6], [7, 8, 9]))
def testStandardSplitRandomize(self): splitter = data_split.StandardSplit() partition1 = splitter.split(range(10)) partition2 = splitter.split(range(10), randomize=True) self.assertNotEqual(partition1, partition2) self.assertItemsEqual(partition1[0] + partition1[1], partition2[0] + partition2[1])
def testStandardSplitNoData(self): splitter = data_split.StandardSplit() with self.assertRaises(ValueError): splitter.split([])
def testStandardSplitBadValue(self): with self.assertRaises(ValueError): data_split.StandardSplit(2)