def test_chunkList(self, its = 100):
     for it in range(its):
         length = random.randint(0, 20)
         numChunks = random.randint(1, 20)
         xs = gen_list(length)
         chunks = ih.chunkList(xs, numChunks)
         assert len(chunks) == numChunks
         # chunks should partition the original list
         assert [ x for chunk in chunks for x in chunk ] == xs
         # chunks should all be roughly the same size
         sizes = set([ len(chunk) for chunk in chunks ])
         assert len(sizes) <= 2
 def test_chunkList(self, its=100):
     for it in range(its):
         length = random.randint(0, 20)
         numChunks = random.randint(1, 20)
         xs = gen_list(length)
         chunks = ih.chunkList(xs, numChunks)
         assert len(chunks) == numChunks
         # chunks should partition the original list
         assert [x for chunk in chunks for x in chunk] == xs
         # chunks should all be roughly the same size
         sizes = set([len(chunk) for chunk in chunks])
         assert len(sizes) <= 2
Exemple #3
0
def getUttIdChunks(corpus, numChunks):
    return chunkList(corpus.trainUttIds, numChunks)
Exemple #4
0
def getUttIdChunks(corpus, numChunks):
    return chunkList(corpus.trainUttIds, numChunks)