示例#1
0
def test_ccode_functions():
    assert ccode(sin(x)**cos(x)) == "pow(sin(x), cos(x))"

    assert ccode(elliptic_e(x)) == ("// Not supported in C:\n"
                                    "// elliptic_e\nelliptic_e(x)")

    n = symbols('n', integer=True)
    assert ccode(Abs(n)) == '// Not supported in C:\n// Abs\nAbs(n)'
    assert ccode(Abs(x)) == 'fabs(x)'

    pytest.raises(TypeError, lambda: ccode(sin(x), assign_to=1))
示例#2
0
def test_ccode_user_functions():
    x = symbols('x', integer=False)
    n = symbols('n', integer=True)
    custom_functions = {
        "ceiling":
        "ceil",
        "Abs": [(lambda x: not x.is_integer, "fabs"),
                (lambda x: x.is_integer, "abs")],
    }
    assert ccode(ceiling(x), user_functions=custom_functions) == "ceil(x)"
    assert ccode(Abs(x), user_functions=custom_functions) == "fabs(x)"
    assert ccode(Abs(n), user_functions=custom_functions) == "abs(n)"
示例#3
0
def test_jscode_exceptions():
    assert jscode(ceiling(x)) == "Math.ceil(x)"
    assert jscode(Abs(x)) == "Math.abs(x)"
示例#4
0
def test_printmethod():
    assert jscode(Abs(x)) == "Math.abs(x)"
示例#5
0
def test_ccode_exceptions():
    assert ccode(ceiling(x)) == "ceil(x)"
    assert ccode(Abs(x)) == "fabs(x)"
    assert ccode(gamma(x)) == "tgamma(x)"