예제 #1
0
def test_combinatorSymmetry():
    tl = to_list()
    tl_n = nop() * tl
    tl2 = to_list()
    prod = from_list([1, 2, 3]) * from_list([4.0, 5.0, 6.0])

    sp = prod >> tl_n >> tl2
    assert sp.run() == ([4.0, 5.0, 6.0], [1, 2, 3])
예제 #2
0
def test_combinatorBug():
    fl1 = from_list([1, 2, 3])
    fl2 = from_list([4.0, 5.0, 6.0])
    prod = fl1 * fl2
    assert prod.processors == [fl1, fl2]

    tl = to_list()
    n1 = nop()
    tl_n = tl * n1
    assert tl_n.processors == [tl, n1]

    tl2 = to_list()

    sp = prod >> (nop() * nop()) >> (tl * tl2)
    assert sp.run() == ([1, 2, 3], [4.0, 5.0, 6.0])

    sp = prod >> tl_n >> tl2
    assert sp.run() == ([1, 2, 3], [4.0, 5.0, 6.0])
예제 #3
0
def to_replacement(i):
    return "{{%s}}" % i[0], i[1]


get_replacements = get_values >> maps(to_replacement)

sp = lp >> get_replacements >> lc

res = sp.run()[0]
print(res)
assert ("{{a}}", "b") in res
assert ("{{c.d}}", "e") in res

# And finally the json string replacer. We do not read from a file with it.
# We need a nop to get the types right.

json_string_replacer = tee() >> nop() * get_replacements >> replace >> to_json

sp = lp >> json_string_replacer >> lc

res = sp.run()[0]
print(res)
assert res["a"] == "b"
assert res["b"] == "b"
assert res["c"] == {"d": "e"}
assert res["e"] == "e"

# Finally, we map a filename to a fully parsed and replace json

json_string_replacer_f = read_file >> json_string_replacer
예제 #4
0
 def producer(self):
     return ((from_list([1, 2, 3]) >> to_list()) *
             (from_list([4, 5, 6]) >> nop()))
예제 #5
0
 def producer(self):
     return (from_list([1, 2, 3]) * from_list([4, 5, 6]) >>
             (to_list() * nop()))
예제 #6
0
 def pipe(self):
     return nop()