Beispiel #1
0
def test_complex():
    def nor_gate(i, j, k):
        c = CRN()

        prom = "P{}{}".format(i, j)

        txn = "{0} > {0} + {1}".format(prom, k)
        deg = "{0} > ".format(k)
        r1 = "{0} + {1} <> {0}{1}".format(prom, i)
        r2 = "{0} + {1} <> {0}{1}".format(prom, j)

        c.r(txn, 1.0, 'txn')
        c.r(deg, 0.1, 'deg')
        c.r(r1, [0.01, 0.05], 'repr')
        c.r(r2, [0.01, 0.0005], 'repr')
        c[prom] = 1
        return c

    c1 = nor_gate("r1", "r1", "r5")
    c2 = nor_gate("r2", "r2", "r6")
    c3 = nor_gate("r5", "r6", "r7")
    c4 = CRN.merge_all([c1, c2, c3])

    c4.r(" > r1", 1.0)
    c4.r("r1 > ", 0.1)

    c4.remove_duplicates()
    c4.reduce()

    df = c4.run(1000)
Beispiel #2
0
def test_merge_maintains_part():
    c = CRN()
    c.r("A + B > 2C", 1, part='part1')

    c2 = CRN()
    c2.r("AB > BC", 1, part='part2')

    c3 = CRN.merge_all([c, c2])
    for r in c3.reactions:
        print(r)
    assert c3.reactions[0].part == 'part1'
    assert c3.reactions[1].part == 'part2'

    print(c3)
Beispiel #3
0
def test_merge_maintains_part():
    c = CRN()
    c.r("A + B > 2C", 1, part='part1')

    c2 = CRN()
    c2.r("AB > BC", 1, part='part2')


    c3 = CRN.merge_all([c, c2])
    for r in c3.reactions:
        print(r)
    assert c3.reactions[0].part == 'part1'
    assert c3.reactions[1].part == 'part2'

    print(c3)
Beispiel #4
0
def test_merge_all():
    c1 = CRN()
    c1.r("A + B <> 2C", [1, 1])
    c1['A'] = 2

    c2 = copy(c1)
    c2['A'] = 4
    c2['B'] = 1

    assert(c1['A'] == 2)
    assert(c1['B'] == 0)
    assert(c1['C'] == 0)
    c3 = CRN.merge_all([c1, c2])
    assert(c3['A'] == 4)
    assert(c3['B'] == 1)
    assert(c3['C'] == 0)
Beispiel #5
0
def test_merge_all():
    c1 = CRN()
    c1.r("A + B <> 2C", [1, 1])
    c1['A'] = 2

    c2 = copy(c1)
    c2['A'] = 4
    c2['B'] = 1

    assert (c1['A'] == 2)
    assert (c1['B'] == 0)
    assert (c1['C'] == 0)
    c3 = CRN.merge_all([c1, c2])
    assert (c3['A'] == 4)
    assert (c3['B'] == 1)
    assert (c3['C'] == 0)
Beispiel #6
0
def test_get_part():
    c = CRN()
    c.r("A + B > 2C", 1, part='part1')

    c2 = CRN()
    c2.r("AB <> BC", [1, 1], part='part2')

    c3 = CRN.merge_all([c, c2])

    c4 = c3.get_part('part1')
    c5 = c3.get_part('part2')
    c6 = c3.get_part('part1', 'part2')

    assert len(c3.reactions) == 3
    assert len(c4.reactions) == 1
    assert len(c5.reactions) == 2
    assert len(c6.reactions) == 3
Beispiel #7
0
def test_get_part():
    c = CRN()
    c.r("A + B > 2C", 1, part='part1')

    c2 = CRN()
    c2.r("AB <> BC", [1,1], part='part2')


    c3 = CRN.merge_all([c, c2])

    c4 = c3.get_part('part1')
    c5 = c3.get_part('part2')
    c6 = c3.get_part('part1', 'part2')

    assert len(c3.reactions) == 3
    assert len(c4.reactions) == 1
    assert len(c5.reactions) == 2
    assert len(c6.reactions) == 3