def test_reduceby_product(data, groups): keyfunc = lambda x: x % 2 == 0 reducefunc = lambda x, y: x * y generator = utils.reduceby(data, keyfunc, reducefunc, 1) assert list(generator) == groups
def test_reduceby_sum(data, groups): keyfunc = lambda x: x // 10 reducefunc = lambda x, y: x + y generator = utils.reduceby(data, keyfunc, reducefunc, 0) assert list(generator) == groups