コード例 #1
0
def test_add_sym():
    e1 = expr_to_c()(sympify('a+b'))
    # comparing to a string is brittle - can we do better?
    # normalize the string - removing spaces might help?
    assert str(e1) == 'b + a'
    e2 = expr_to_c()(sympify('a+b+c'))
    print str(e2)
    assert str(e2) == 'b + a + c'
コード例 #2
0
def test_add_sym():
    e1 = expr_to_c()(sympify('a+b'))
    # comparing to a string is brittle - can we do better?
    # normalize the string - removing spaces might help?
    assert str(e1) == 'b + a'
    e2 = expr_to_c()(sympify('a+b+c'))
    print str(e2)
    assert str(e2) == 'b + a + c'
コード例 #3
0
def test_var():
    a = Symbol('a')
    e = expr_to_c()(a)
    assert str(e) == 'a'
コード例 #4
0
def test_div():
    e1 = expr_to_c()(sympify('a/b'))
    assert str(e1) == 'a / b'
    e2 = expr_to_c()(sympify('1.0/b'))
    assert str(e2) == '1.0 / b'
コード例 #5
0
def test_add_and_mul():
    e1 = expr_to_c()(sympify('a+2*b'))
    assert str(e1) == '2 * b + a'
コード例 #6
0
def test_mul():
    e1 = expr_to_c()(sympify('a*b'))
    print 'e1 = ', str(e1)
    assert str(e1) == 'a * b'
    e2 = expr_to_c()(sympify('2*b'))
    assert str(e2) == '2 * b'
コード例 #7
0
def test_add_sym_to_num():
    e = expr_to_c()(sympify('a+1'))
    assert str(e) == '1 + a'
コード例 #8
0
def test_var():
    a = Symbol('a')
    e = expr_to_c()(a)
    assert str(e) == 'a'
コード例 #9
0
def test_div():
    e1 = expr_to_c()(sympify('a/b'))
    assert str(e1) == 'a / b'
    e2 = expr_to_c()(sympify('1.0/b'))
    assert str(e2) == '1.0 / b'
コード例 #10
0
def test_add_and_mul():
    e1 = expr_to_c()(sympify('a+2*b'))
    assert str(e1) == '2 * b + a'
コード例 #11
0
def test_mul():
    e1 = expr_to_c()(sympify('a*b'))
    print 'e1 = ',str(e1)
    assert str(e1) == 'a * b'
    e2 = expr_to_c()(sympify('2*b'))
    assert str(e2) == '2 * b'
コード例 #12
0
def test_add_sym_to_num():
    e = expr_to_c()(sympify('a+1'))
    assert str(e) == '1 + a'