• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sympy.raises函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sympy.raises函数的典型用法代码示例。如果您正苦于以下问题:Python raises函数的具体用法?Python raises怎么用?Python raises使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了raises函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_dmp_rr_div

def test_dmp_rr_div():
    raises(ZeroDivisionError, "dmp_rr_div([[1,2],[3]], [[]], 1, ZZ)")

    f = dmp_normal([[1], [], [1, 0, 0]], 1, ZZ)
    g = dmp_normal([[1], [-1, 0]], 1, ZZ)

    q = dmp_normal([[1], [1, 0]], 1, ZZ)
    r = dmp_normal([[2, 0, 0]], 1, ZZ)

    assert dmp_rr_div(f, g, 1, ZZ) == (q, r)

    f = dmp_normal([[1], [], [1, 0, 0]], 1, ZZ)
    g = dmp_normal([[-1], [1, 0]], 1, ZZ)

    q = dmp_normal([[-1], [-1, 0]], 1, ZZ)
    r = dmp_normal([[2, 0, 0]], 1, ZZ)

    assert dmp_rr_div(f, g, 1, ZZ) == (q, r)

    f = dmp_normal([[1], [], [1, 0, 0]], 1, ZZ)
    g = dmp_normal([[2], [-2, 0]], 1, ZZ)

    q, r = [[]], f

    assert dmp_rr_div(f, g, 1, ZZ) == (q, r)
开发者ID:unix0000,项目名称:sympy-polys,代码行数:25,代码来源:test_densearith.py


示例2: test_gf_irreducible_p

def test_gf_irreducible_p():
    assert gf_irred_p_ben_or([7], 11, ZZ) == True
    assert gf_irred_p_ben_or([7,3], 11, ZZ) == True
    assert gf_irred_p_ben_or([7,3,1], 11, ZZ) == False

    assert gf_irred_p_rabin([7], 11, ZZ) == True
    assert gf_irred_p_rabin([7,3], 11, ZZ) == True
    assert gf_irred_p_rabin([7,3,1], 11, ZZ) == False

    assert gf_irreducible_p([7], 11, ZZ, method='ben-or') == True
    assert gf_irreducible_p([7,3], 11, ZZ, method='ben-or') == True
    assert gf_irreducible_p([7,3,1], 11, ZZ, method='ben-or') == False

    assert gf_irreducible_p([7], 11, ZZ, method='rabin') == True
    assert gf_irreducible_p([7,3], 11, ZZ, method='rabin') == True
    assert gf_irreducible_p([7,3,1], 11, ZZ, method='rabin') == False

    raises(KeyError, "gf_irreducible_p([7], 11, ZZ, method='other')")

    f = [1, 9,  9, 13, 16, 15,  6,  7,  7,  7, 10]
    g = [1, 7, 16,  7, 15, 13, 13, 11, 16, 10,  9]

    h = gf_mul(f, g, 17, ZZ)

    assert gf_irred_p_ben_or(f, 17, ZZ) == True
    assert gf_irred_p_ben_or(g, 17, ZZ) == True

    assert gf_irred_p_ben_or(h, 17, ZZ) == False

    assert gf_irred_p_rabin(f, 17, ZZ) == True
    assert gf_irred_p_rabin(g, 17, ZZ) == True

    assert gf_irred_p_rabin(h, 17, ZZ) == False
开发者ID:Sumith1896,项目名称:sympy-polys,代码行数:33,代码来源:test_galoistools.py


示例3: test_lambda

def test_lambda():
    x = Symbol('x')
    assert sympify('lambda : 1') == Lambda(x, 1)
    assert sympify('lambda x: 2*x') == Lambda(x, 2*x)
    assert sympify('lambda x, y: 2*x+y') == Lambda([x, y], 2*x+y)

    raises(SympifyError, "_sympify('lambda : 1')")
开发者ID:KevinGoodsell,项目名称:sympy,代码行数:7,代码来源:test_sympify.py


示例4: test_dmp_ff_div

def test_dmp_ff_div():
    raises(ZeroDivisionError, "dmp_ff_div([[1,2],[3]], [[]], 1, QQ)")

    f = dmp_normal([[1], [], [1, 0, 0]], 1, QQ)
    g = dmp_normal([[1], [-1, 0]], 1, QQ)

    q = [[QQ(1, 1)], [QQ(1, 1), QQ(0, 1)]]
    r = [[QQ(2, 1), QQ(0, 1), QQ(0, 1)]]

    assert dmp_ff_div(f, g, 1, QQ) == (q, r)

    f = dmp_normal([[1], [], [1, 0, 0]], 1, QQ)
    g = dmp_normal([[-1], [1, 0]], 1, QQ)

    q = [[QQ(-1, 1)], [QQ(-1, 1), QQ(0, 1)]]
    r = [[QQ(2, 1), QQ(0, 1), QQ(0, 1)]]

    assert dmp_ff_div(f, g, 1, QQ) == (q, r)

    f = dmp_normal([[1], [], [1, 0, 0]], 1, QQ)
    g = dmp_normal([[2], [-2, 0]], 1, QQ)

    q = [[QQ(1, 2)], [QQ(1, 2), QQ(0, 1)]]
    r = [[QQ(2, 1), QQ(0, 1), QQ(0, 1)]]

    assert dmp_ff_div(f, g, 1, QQ) == (q, r)
开发者ID:unix0000,项目名称:sympy-polys,代码行数:26,代码来源:test_densearith.py


示例5: test_solve_poly_system

def test_solve_poly_system():
    assert solve_poly_system([x-1], x) == [(S.One,)]

    assert solve_poly_system([y - x, y - x - 1], x, y) == None

    assert solve_poly_system([y - x**2, y + x**2], x, y) == [(S.Zero, S.Zero)]

    assert solve_poly_system([2*x - 3, 3*y/2 - 2*x, z - 5*y], x, y, z) == \
        [(Rational(3, 2), Integer(2), Integer(10))]

    assert solve_poly_system([x*y - 2*y, 2*y**2 - x**2], x, y) == \
       [(0, 0), (2, -2**S.Half), (2, 2**S.Half)]

    assert solve_poly_system([y - x**2, y + x**2 + 1], x, y) == \
           [(I*S.Half**S.Half, -S.Half), (-I*S.Half**S.Half, -S.Half)]

    a, b = -1 - 2**S.Half, -1 + 2**S.Half

    assert solve_poly_system([x**2+y+z-1, x+y**2+z-1, x+y+z**2-1], x, y, z) == \
        [(a, a, a), (0, 0, 1), (0, 1, 0), (b, b, b), (1, 0, 0)]

    solution = [(1, -1), (1, 1)]

    assert solve_poly_system([Poly(x**2 - y**2), Poly(x - 1)]) == solution
    assert solve_poly_system([x**2 - y**2, x - 1], x, y) == solution
    assert solve_poly_system([x**2 - y**2, x - 1]) == solution

    raises(ValueError, "solve_poly_system([x**3-y**3], x, y)")
开发者ID:Sumith1896,项目名称:sympy-polys,代码行数:28,代码来源:test_polysys.py


示例6: test_var

def test_var():
    var("a")
    assert a  == Symbol("a")

    var("b bb cc zz _x")
    assert b  == Symbol("b")
    assert bb == Symbol("bb")
    assert cc == Symbol("cc")
    assert zz == Symbol("zz")
    assert _x == Symbol("_x")

    v = var(['d','e','fg'])
    assert d  == Symbol('d')
    assert e  == Symbol('e')
    assert fg == Symbol('fg')

    # check return value
    assert v  == (d, e, fg)

    # see if var() really injects into global namespace
    raises(NameError, "z1")
    make_z1()
    assert z1 == Symbol("z1")

    raises(NameError, "z2")
    make_z2()
    assert z2 == Symbol("z2")
开发者ID:Praveen-Ramanujam,项目名称:MobRAVE,代码行数:27,代码来源:test_var.py


示例7: test_poly_cancel

def test_poly_cancel():
    assert Poly.cancel(x) == x
    assert Poly.cancel(x+1) == x+1
    assert Poly.cancel((x+1)/(1-x)) == (x+1)/(1-x)

    assert Poly.cancel((x**2-1)/(x-1)) == x+1
    assert Poly.cancel((x**2-y**2)/(x-y)) == x+y

    assert Poly.cancel((x**2-y)/(x-y)) == (x**2 - y)/(x - y)
    assert Poly.cancel((x**2-2)/(x+sqrt(2))) == x - sqrt(2)

    assert Poly.cancel((x**2-y**2)/(x-y), x) == x+y

    assert Poly.cancel((x, S.One), x) == x
    assert Poly.cancel((x+1, S.One), x) == x+1
    assert Poly.cancel((x+1, x-1), x) == (x+1)/(x-1)

    assert Poly.cancel((x**2-1, x-1), x) == x+1
    assert Poly.cancel((x**2-y**2, x-y), x, y) == x+y

    assert Poly.cancel((x**2-y, x-y), x, y) == (x**2 - y)/(x - y)
    assert Poly.cancel((x**2-2, x+sqrt(2)), x) == x - sqrt(2)

    assert Poly.cancel((x**2-y**2, x-y), x) == x+y

    assert Poly.cancel(((x**2-y**2).as_poly(x), (x-y).as_poly(x))) == x+y

    f = -1/(3 + 2*sqrt(2))*(1 + 1/(3 + 2*sqrt(2))*(7 + 5*sqrt(2)))

    assert Poly.cancel(f) == -2 + sqrt(2)

    raises(SymbolsError, "Poly.cancel((x**2-y**2, x-y))")
开发者ID:jcockayne,项目名称:sympy-rkern,代码行数:32,代码来源:test_polynomial.py


示例8: test_poly_nth

def test_poly_nth():
    assert poly_nth([1,2,3], 0) == 3
    assert poly_nth([1,2,3], 1) == 2
    assert poly_nth([1,2,3], 2) == 1

    raises(IndexError, 'poly_nth([3,4,5],-1)')
    raises(IndexError, 'poly_nth([3,4,5], 3)')
开发者ID:Praveen-Ramanujam,项目名称:MobRAVE,代码行数:7,代码来源:test_integerpolys.py


示例9: test_sympify3

def test_sympify3():
    assert sympify("x**3") == x**3
    assert sympify("x^3") == x**3
    assert sympify("1/2") == Integer(1)/2

    raises(SympifyError, "_sympify('x**3')")
    raises(SympifyError, "_sympify('1/2')")
开发者ID:KevinGoodsell,项目名称:sympy,代码行数:7,代码来源:test_sympify.py


示例10: test_solve_polynomial1

def test_solve_polynomial1():
    x, y = symbols('xy')

    assert solve(3*x-2, x) == [Rational(2,3)]
    assert solve(Eq(3*x, 2), x) == [Rational(2,3)]

    assert solve(x**2-1, x) in [[-1, 1], [1, -1]]
    assert solve(Eq(x**2, 1), x) in [[-1, 1], [1, -1]]

    assert solve( x - y**3, x) == [y**3]
    assert sorted(solve( x - y**3, y)) == sorted([
        (-x**Rational(1,3))/2 + I*sqrt(3)*x**Rational(1,3)/2,
        x**Rational(1,3),
        (-x**Rational(1,3))/2 - I*sqrt(3)*x**Rational(1,3)/2,
    ])

    a11,a12,a21,a22,b1,b2 = symbols('a11','a12','a21','a22','b1','b2')

    assert solve([a11*x + a12*y - b1, a21*x + a22*y - b2], x, y) == \
        { y : (a11*b2 - a21*b1)/(a11*a22 - a12*a21),
          x : (a22*b1 - a12*b2)/(a11*a22 - a12*a21) }

    solution = {y: S.Zero, x: S.Zero}

    assert solve((x-y, x+y),  x, y ) == solution
    assert solve((x-y, x+y), (x, y)) == solution
    assert solve((x-y, x+y), [x, y]) == solution

    assert solve( x**3 - 15*x - 4, x) == [-2 + 3**Rational(1,2),
                                           4,
                                           -2 - 3**Rational(1,2) ]

    raises(TypeError, "solve(x**2-pi, pi)")
    raises(ValueError, "solve(x**2-pi)")
开发者ID:cran,项目名称:rSymPy,代码行数:34,代码来源:test_solvers.py


示例11: test_interval_symbolic

def test_interval_symbolic():
    x = Symbol('x')
    e = Interval(0, 1)
    assert e.contains(x) == And(0<=x, x<=1)
    raises(TypeError, "x in e")
    e = Interval(0, 1, True, True)
    assert e.contains(x) == And(0<x, x<1)
开发者ID:Sumith1896,项目名称:sympy-polys,代码行数:7,代码来源:test_sets.py


示例12: test_union

def test_union():
    assert Union(Interval(1, 2), Interval(2, 3)) == Interval(1, 3)
    assert Union(Interval(1, 2), Interval(2, 3, True)) == Interval(1, 3)
    assert Union(Interval(1, 3), Interval(2, 4)) == Interval(1, 4)
    assert Union(Interval(1, 2), Interval(1, 3)) == Interval(1, 3)
    assert Union(Interval(1, 3), Interval(1, 2)) == Interval(1, 3)
    assert Union(Interval(1, 3, False, True), Interval(1, 2)) == \
           Interval(1, 3, False, True)
    assert Union(Interval(1, 3), Interval(1, 2, False, True)) == Interval(1, 3)
    assert Union(Interval(1, 2, True), Interval(1, 3)) == Interval(1, 3)
    assert Union(Interval(1, 2, True), Interval(1, 3, True)) == Interval(1, 3, True)
    assert Union(Interval(1, 2, True), Interval(1, 3, True, True)) == \
           Interval(1, 3, True, True)
    assert Union(Interval(1, 2, True, True), Interval(1, 3, True)) == \
           Interval(1, 3, True)
    assert Union(Interval(1, 3), Interval(2, 3)) == Interval(1, 3)
    assert Union(Interval(1, 3, False, True), Interval(2, 3)) == \
           Interval(1, 3)
    assert Union(Interval(1, 2, False, True), Interval(2, 3, True)) != \
           Interval(1, 3)
    assert Union(Interval(1, 2), S.EmptySet) == Interval(1, 2)
    assert Union(S.EmptySet) == S.EmptySet

    assert Interval(1, 2).union(Interval(2, 3)) == \
           Interval(1, 2) + Interval(2, 3)

    assert Interval(1, 2).union(Interval(2, 3)) == Interval(1, 3)

    assert Union(Set()) == Set()

    raises(ValueError, "Union(1, 2, 3)")
开发者ID:KevinGoodsell,项目名称:sympy,代码行数:31,代码来源:test_sets.py


示例13: test__dict_from_basic_if_gens

def test__dict_from_basic_if_gens():
    assert _dict_from_basic_if_gens(Integer(17), (x,)) == {(0,): Integer(17)}
    assert _dict_from_basic_if_gens(Integer(17), (x,y)) == {(0,0): Integer(17)}
    assert _dict_from_basic_if_gens(Integer(17), (x,y,z)) == {(0,0,0): Integer(17)}

    assert _dict_from_basic_if_gens(Integer(-17), (x,)) == {(0,): Integer(-17)}
    assert _dict_from_basic_if_gens(Integer(-17), (x,y)) == {(0,0): Integer(-17)}
    assert _dict_from_basic_if_gens(Integer(-17), (x,y,z)) == {(0,0,0): Integer(-17)}

    assert _dict_from_basic_if_gens(Integer(17)*x, (x,)) == {(1,): Integer(17)}
    assert _dict_from_basic_if_gens(Integer(17)*x, (x,y)) == {(1,0): Integer(17)}
    assert _dict_from_basic_if_gens(Integer(17)*x, (x,y,z)) == {(1,0,0): Integer(17)}

    assert _dict_from_basic_if_gens(Integer(17)*x**7, (x,)) == {(7,): Integer(17)}
    assert _dict_from_basic_if_gens(Integer(17)*x**7*y, (x,y)) == {(7,1): Integer(17)}
    assert _dict_from_basic_if_gens(Integer(17)*x**7*y*z**12, (x,y,z)) == {(7,1,12): Integer(17)}

    assert _dict_from_basic_if_gens(x+2*y+3*z, (x,)) == \
        {(1,): Integer(1), (0,): 2*y+3*z}
    assert _dict_from_basic_if_gens(x+2*y+3*z, (x,y)) == \
        {(1,0): Integer(1), (0,1): Integer(2), (0,0): 3*z}
    assert _dict_from_basic_if_gens(x+2*y+3*z, (x,y,z)) == \
        {(1,0,0): Integer(1), (0,1,0): Integer(2), (0,0,1): Integer(3)}

    assert _dict_from_basic_if_gens(x*y+2*x*z+3*y*z, (x,)) == \
        {(1,): y+2*z, (0,): 3*y*z}
    assert _dict_from_basic_if_gens(x*y+2*x*z+3*y*z, (x,y)) == \
        {(1,1): Integer(1), (1,0): 2*z, (0,1): 3*z}
    assert _dict_from_basic_if_gens(x*y+2*x*z+3*y*z, (x,y,z)) == \
        {(1,1,0): Integer(1), (1,0,1): Integer(2), (0,1,1): Integer(3)}

    assert _dict_from_basic_if_gens(2**y*x, (x,)) == {(1,): 2**y}
    raises(PolynomialError, "_dict_from_basic_if_gens(2**y*x, (x,y))")
开发者ID:Sumith1896,项目名称:sympy-polys,代码行数:33,代码来源:test_polyutils.py


示例14: test_tsolve_1

def test_tsolve_1():
    a, b = symbols('ab')
    x, y, z = symbols('xyz')
    assert solve(exp(x)-3, x) == [log(3)]
    assert solve((a*x+b)*(exp(x)-3), x) == [-b/a, log(3)]
    assert solve(cos(x)-y, x) == [acos(y)]
    assert solve(2*cos(x)-y,x)== [acos(y/2)]
    raises(NotImplementedError, "solve(Eq(cos(x), sin(x)), x)")

    # XXX in the following test, log(2*y + 2*...) should -> log(2) + log(y +...)
    assert solve(exp(x)+exp(-x)-y,x)    == [-log(4) + log(2*y + 2*(-4 + y**2)**Rational(1,2)),
                                            -log(4) + log(2*y - 2*(-4 + y**2)**Rational(1,2))]
    assert solve(exp(x)-3, x) == [log(3)]
    assert solve(Eq(exp(x), 3), x) == [log(3)]
    assert solve(log(x)-3, x) == [exp(3)]
    assert solve(sqrt(3*x)-4, x) == [Rational(16,3)]
    assert solve(3**(x+2), x) == [-oo]
    assert solve(3**(2-x), x) == [oo]
    assert solve(4*3**(5*x+2)-7, x) == [(-log(4) - 2*log(3) + log(7))/(5*log(3))]
    assert solve(x+2**x, x) == [-LambertW(log(2))/log(2)]
    assert solve(3*x+5+2**(-5*x+3), x) in \
        [[-Rational(5,3) + LambertW(-10240*2**Rational(1,3)*log(2)/3)/(5*log(2))],\
        [(-25*log(2) + 3*LambertW(-10240*2**(Rational(1, 3))*log(2)/3))/(15*log(2))]]
    assert solve(5*x-1+3*exp(2-7*x), x) == \
        [Rational(1,5) + LambertW(-21*exp(Rational(3,5))/5)/7]
    assert solve(2*x+5+log(3*x-2), x) == \
        [Rational(2,3) + LambertW(2*exp(-Rational(19,3))/3)/2]
    assert solve(3*x+log(4*x), x) == [LambertW(Rational(3,4))/3]
    assert solve((2*x+8)*(8+exp(x)), x) == [-4, log(8) + pi*I]
    assert solve(2*exp(3*x+4)-3, x) in [ [-Rational(4,3)+log(Rational(3,2))/3],\
                                         [Rational(-4, 3) - log(2)/3 + log(3)/3]]
    assert solve(2*log(3*x+4)-3, x) == [(exp(Rational(3,2))-4)/3]
    assert solve(exp(x)+1, x) == [pi*I]
    assert solve(x**2 - 2**x, x) == [2]
    assert solve(x**3 - 3**x, x) == [-3/log(3)*LambertW(-log(3)/3)]
    assert solve(2*(3*x+4)**5 - 6*7**(3*x+9), x) in \
        [[Rational(-4,3) - 5/log(7)/3*LambertW(-7*2**Rational(4,5)*6**Rational(1,5)*log(7)/10)],\
         [(-5*LambertW(-7*2**(Rational(4, 5))*6**(Rational(1, 5))*log(7)/10) - 4*log(7))/(3*log(7))], \
         [-((4*log(7) + 5*LambertW(-7*2**Rational(4,5)*6**Rational(1,5)*log(7)/10))/(3*log(7)))]]

    assert solve(z*cos(x)-y, x)      == [acos(y/z)]
    assert solve(z*cos(2*x)-y, x)    == [acos(y/z)/2]
    assert solve(z*cos(sin(x))-y, x) == [asin(acos(y/z))]

    assert solve(z*cos(x), x)        == [acos(0)]

    assert solve(exp(x)+exp(-x)-y, x)== [-log(4) + log(2*y + 2*(-4 + y**2)**(Rational(1, 2))),
                                          -log(4) + log(2*y - 2*(-4 + y**2)**(Rational(1, 2)))]
    # issue #1409
    assert solve(y - b*x/(a+x), x) in [[-a*y/(y - b)], [a*y/(b - y)]]
    assert solve(y - b*exp(a/x), x) == [a/(-log(b) + log(y))]
    # issue #1408
    assert solve(y-b/(1+a*x),x) == [(b - y)/(a*y)]
    # issue #1407
    assert solve(y-a*x**b , x) == [y**(1/b)*(1/a)**(1/b)]
    # issue #1406
    assert solve(z**x - y, x) == [log(y)/log(z)]
    # issue #1405
    assert solve(2**x - 10, x) == [log(10)/log(2)]
开发者ID:Sumith1896,项目名称:sympy-polys,代码行数:59,代码来源:test_solvers.py


示例15: test_dmp_nth

def test_dmp_nth():
    assert dmp_nth([[1],[2],[3]], 0, 1, ZZ) == [3]
    assert dmp_nth([[1],[2],[3]], 1, 1, ZZ) == [2]
    assert dmp_nth([[1],[2],[3]], 2, 1, ZZ) == [1]

    assert dmp_nth([[1],[2],[3]], 9, 1, ZZ) == []

    raises(IndexError, 'dmp_nth([[3],[4],[5]], -1, 1, ZZ)')
开发者ID:Sumith1896,项目名称:sympy-polys,代码行数:8,代码来源:test_densebasic.py


示例16: test_dup_nth

def test_dup_nth():
    assert dup_nth([1,2,3], 0, ZZ) == 3
    assert dup_nth([1,2,3], 1, ZZ) == 2
    assert dup_nth([1,2,3], 2, ZZ) == 1

    assert dup_nth([1,2,3], 9, ZZ) == 0

    raises(IndexError, 'dup_nth([3,4,5], -1, ZZ)')
开发者ID:Sumith1896,项目名称:sympy-polys,代码行数:8,代码来源:test_densebasic.py


示例17: test_dmp_validate

def test_dmp_validate():
    assert dmp_validate([]) == ([], 0)
    assert dmp_validate([0,0,0,1,0]) == ([1,0], 0)

    assert dmp_validate([[[]]]) == ([[[]]], 2)
    assert dmp_validate([[0],[],[0],[1],[0]]) == ([[1],[]], 1)

    raises(ValueError, 'dmp_validate([[0],0,[0],[1],[0]])')
开发者ID:Sumith1896,项目名称:sympy-polys,代码行数:8,代码来源:test_densebasic.py


示例18: test_swinnerton_dyer_poly

def test_swinnerton_dyer_poly():
    raises(ValueError, "swinnerton_dyer_poly(0, x)")

    assert swinnerton_dyer_poly(1, x, polys=True) == Poly(x**2 - 2)

    assert swinnerton_dyer_poly(1, x) == x**2 - 2
    assert swinnerton_dyer_poly(2, x) == x**4 - 10*x**2 + 1
    assert swinnerton_dyer_poly(3, x) == x**8 - 40*x**6 + 352*x**4 - 960*x**2 + 576
开发者ID:Sumith1896,项目名称:sympy-polys,代码行数:8,代码来源:test_specialpolys.py


示例19: test_as_integer

def test_as_integer():
    assert Poly(3*x**2 + x, x).as_integer() == \
        (Integer(1), Poly(3*x**2 + x, x))

    assert Poly(x**2 + x/2, x).as_integer() == \
        (Integer(2), Poly(2*x**2 + x, x))

    raises(CoefficientError, "Poly(x**2 + t*x, x).as_integer()")
开发者ID:jcockayne,项目名称:sympy-rkern,代码行数:8,代码来源:test_polynomial.py


示例20: test_zzx_compose_term

def test_zzx_compose_term():
    assert zzx_compose_term([], 17) == []

    assert zzx_compose_term([1,2,3], 1) == [1, 2, 3]
    assert zzx_compose_term([1,2,3], 2) == [1, 0, 2, 0, 3]
    assert zzx_compose_term([1,2,3], 3) == [1, 0, 0, 2, 0, 0, 3]
    assert zzx_compose_term([1,2,3], 4) == [1, 0, 0, 0, 2, 0, 0, 0, 3]

    raises(ValueError, 'zzx_compose_term([1,2,3], 0)')
开发者ID:Praveen-Ramanujam,项目名称:MobRAVE,代码行数:9,代码来源:test_integerpolys.py



注:本文中的sympy.raises函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sympy.ratsimp函数代码示例发布时间:2022-05-27
下一篇:
Python sympy.radsimp函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap