예제 #1
0
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
예제 #2
0
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
예제 #3
0
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
예제 #4
0
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