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()
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()
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
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
def _test_bool_optimized(lst): if SEQ: lst = OSList.raw(lst) else: lst = OPList.raw(lst) return _test_bool_direct(lst)
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
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
def test_plist_constructor(): # pylint: disable=missing-docstring exp = DPList().to_seq() res = PList().to_seq().run() assert res == exp