def test_empty(self): chunks = [chunked(range(0), 0), chunked(range(0), -1), chunked(range(0), None), chunked(range(0), 3), chunked(range(0), 3, partial=True)] for chunk in chunks: self.assert_iter_equal(chunk, [])
def test_empty(self): chunks = [ chunked(range(0), 0), chunked(range(0), -1), chunked(range(0), None), chunked(range(0), 3), chunked(range(0), 3, partial=True) ] for chunk in chunks: self.assert_iter_equal(chunk, [])
def test_chop_partial(self): size = 3 self.assert_iter_equal( chopped(windowed(range(4), size, 1, partial=True), size), [(0, 1, 2), (1, 2, 3)]) self.assert_iter_equal( chopped(chunked(range(7), size, partial=True), size), [(0, 1, 2), (3, 4, 5)])
def test_partial(self): self.assert_iter_equal(chunked(range(4), 3, partial=True), [(0, 1, 2), (3, )]) self.assert_iter_equal(chunked(range(2), 3, partial=True), [(0, 1)])
def test_single(self): self.assert_iter_equal(chunked(range(1), 1), [(0, )]) self.assert_iter_equal(chunked(range(1), 2), [])
def test_no_partial(self): self.assert_iter_equal(chunked(range(7), 3), [(0, 1, 2), (3, 4, 5)]) self.assert_iter_equal(chunked(range(6), 3), [(0, 1, 2), (3, 4, 5)]) self.assert_iter_equal(chunked(range(2), 3), [])
def test_chop_partial(self): size = 3 self.assert_iter_equal(chopped(windowed(range(4), size, 1, partial=True), size), [(0, 1, 2), (1, 2, 3)]) self.assert_iter_equal(chopped(chunked(range(7), size, partial=True), size), [(0, 1, 2), (3, 4, 5)])
def test_partial(self): self.assert_iter_equal(chunked(range(4), 3, partial=True), [(0, 1, 2), (3,)]) self.assert_iter_equal(chunked(range(2), 3, partial=True), [(0, 1)])
def test_single(self): self.assert_iter_equal(chunked(range(1), 1), [(0,)]) self.assert_iter_equal(chunked(range(1), 2), [])