示例#1
0
 def __compute():
     if test == _DIRECT:
         return dot_product(pl1, pl2)
     if test == _HAND:
         return pl2.map2(mul, pl1).reduce(add, 0)
     if test == _EVAL:
         return dot_product(PList.raw(pl1),
                            PList.raw(pl2),
                            uncurry=opt.uncurry).eval()
     return dot_product(PList.raw(pl1), PList.raw(pl2),
                        uncurry=opt.uncurry).run()
示例#2
0
 def __compute():
     if test == _DIRECT:
         return opt_dot_product(pl1, pl2)
     if test == _HAND:
         return dot_product(pl1, pl2)
     if test == _EVAL:
         return opt_dot_product(PList.raw(pl1),
                                PList.raw(pl2),
                                uncurry=opt.uncurry).eval()
     return opt_dot_product(PList.raw(pl1),
                            PList.raw(pl2),
                            uncurry=opt.uncurry).run()
示例#3
0
def _test_mmr_optimized(lst):
    if SEQ:
        lst1 = OSList.raw(lst)
    else:
        lst1 = OPList.raw(lst)
    lst2 = lst1.map(_f_map)
    lst3 = lst2.map(_f_map)
    res = lst3.reduce(_f_reduce, 0)
    return res
示例#4
0
def _wrapped_vavg(lst):
    scalar = 1 / lst.length()
    lst = OSList.raw(lst) if SEQ else OPList.raw(lst)
    skel = _vnsum(lst).opt()
    res = smul(scalar, skel.eval())
    return res
示例#5
0
def _test_bool_optimized(lst):
    if SEQ:
        lst = OSList.raw(lst)
    else:
        lst = OPList.raw(lst)
    return _test_bool_direct(lst)
示例#6
0
def test_plist_with_raw():
    # pylint: disable=missing-docstring
    input_list = DPList.init(idt, 42)
    exp = input_list.map(incr).map(incr).reduce(add)
    res = PList.raw(input_list).map(incr).map(incr).reduce(add).run()
    assert res == exp
示例#7
0
def test_plist():
    # pylint: disable=missing-docstring
    exp = DPList.init(idt, 10).map(incr).map(incr).reduce(add)
    res = PList.init(idt, 10).map(incr).map(incr).reduce(add).run()
    assert res == exp
示例#8
0
def test_plist_constructor():
    # pylint: disable=missing-docstring
    exp = DPList().to_seq()
    res = PList().to_seq().run()
    assert res == exp