本文整理汇总了Python中sympy.Integer类的典型用法代码示例。如果您正苦于以下问题:Python Integer类的具体用法?Python Integer怎么用?Python Integer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Integer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_has_any
def test_has_any():
x,y,z,t,u = symbols('x y z t u')
f = Function("f")
g = Function("g")
p = Wild('p')
assert sin(x).has(x)
assert sin(x).has(sin)
assert not sin(x).has(y)
assert not sin(x).has(cos)
assert f(x).has(x)
assert f(x).has(f)
assert not f(x).has(y)
assert not f(x).has(g)
assert f(x).diff(x).has(x)
assert f(x).diff(x).has(f)
assert f(x).diff(x).has(Derivative)
assert not f(x).diff(x).has(y)
assert not f(x).diff(x).has(g)
assert not f(x).diff(x).has(sin)
assert (x**2).has(Symbol)
assert not (x**2).has(Wild)
assert (2*p).has(Wild)
i = Integer(4400)
assert i.has(x) is False
assert (i*x**i).has(x)
assert (i*y**i).has(x) is False
assert (i*y**i).has(x, y)
expr = x**2*y + sin(2**t + log(z))
assert expr.has(u) is False
assert expr.has(x)
assert expr.has(y)
assert expr.has(z)
assert expr.has(t)
assert expr.has(x, y, z, t)
assert expr.has(x, y, z, t, u)
from sympy.physics.units import m, s
assert (x*m/s).has(x)
assert (x*m/s).has(y, z) is False
poly = Poly(x**2 + x*y*sin(z), x, y, t)
assert poly.has(x)
assert poly.has(x, y, z)
assert poly.has(x, y, z, t)
assert FockState((x, y)).has(x)
开发者ID:qmattpap,项目名称:sympy,代码行数:58,代码来源:test_expr.py
示例2: _big_delta_coeff
def _big_delta_coeff(aa, bb, cc, prec=None):
r"""
Calculates the Delta coefficient of the 3 angular momenta for
Racah symbols. Also checks that the differences are of integer
value.
INPUT:
- ``aa`` - first angular momentum, integer or half integer
- ``bb`` - second angular momentum, integer or half integer
- ``cc`` - third angular momentum, integer or half integer
- ``prec`` - precision of the ``sqrt()`` calculation
OUTPUT:
double - Value of the Delta coefficient
EXAMPLES::
sage: from sage.functions.wigner import _big_delta_coeff
sage: _big_delta_coeff(1,1,1)
1/2*sqrt(1/6)
"""
if int(aa + bb - cc) != (aa + bb - cc):
raise ValueError("j values must be integer or half integer and fulfill the triangle relation")
if int(aa + cc - bb) != (aa + cc - bb):
raise ValueError("j values must be integer or half integer and fulfill the triangle relation")
if int(bb + cc - aa) != (bb + cc - aa):
raise ValueError("j values must be integer or half integer and fulfill the triangle relation")
if (aa + bb - cc) < 0:
return 0
if (aa + cc - bb) < 0:
return 0
if (bb + cc - aa) < 0:
return 0
maxfact = max(aa + bb - cc, aa + cc - bb, bb + cc - aa, aa + bb + cc + 1)
_calc_factlist(maxfact)
argsqrt = Integer(_Factlist[int(aa + bb - cc)] * \
_Factlist[int(aa + cc - bb)] * \
_Factlist[int(bb + cc - aa)]) / \
Integer(_Factlist[int(aa + bb + cc + 1)])
ressqrt = argsqrt.sqrt(prec)
if type(ressqrt) is ComplexNumber:
res = ressqrt.real()
else:
res = ressqrt
return res
开发者ID:Aang,项目名称:sympy,代码行数:53,代码来源:wigner.py
示例3: test_power
def test_power():
x,y,a,b,c = map(Symbol, 'xyabc')
p,q,r = map(Wild, 'pqr')
e = (x+y)**a
assert e.match(p**q) == {p: x+y, q: a}
assert e.match(p**p) == None
e = (x+y)**(x+y)
assert e.match(p**p) == {p: x+y}
assert e.match(p**q) == {p: x+y, q: x+y}
e = (2*x)**2
assert e.match(p*q**r) == {p: 4, q: x, r: 2}
e = Integer(1)
assert e.match(x**p) == {p: 0}
开发者ID:cran,项目名称:rSymPy,代码行数:17,代码来源:test_match.py
示例4: test_has_multiple
def test_has_multiple():
f = x ** 2 * y + sin(2 ** t + log(z))
assert f.has(x)
assert f.has(y)
assert f.has(z)
assert f.has(t)
assert not f.has(u)
assert f.has(x, y, z, t)
assert f.has(x, y, z, t, u)
i = Integer(4400)
assert not i.has(x)
assert (i * x ** i).has(x)
assert not (i * y ** i).has(x)
assert (i * y ** i).has(x, y)
assert not (i * y ** i).has(x, z)
开发者ID:Botouls,项目名称:sympy,代码行数:21,代码来源:test_expr.py
示例5: test_has_any_symbols
def test_has_any_symbols():
x,y,z,t,u = symbols('xyztu')
i = Integer(4400)
assert i.has_any_symbols(x) == False
assert (i*x**i).has_any_symbols(x) == True
assert (i*y**i).has_any_symbols(x) == False
assert (i*y**i).has_any_symbols(x, y) == True
expr = x**2*y + sin(2**t + log(z))
assert expr.has_any_symbols(u) == False
assert expr.has_any_symbols(x) == True
assert expr.has_any_symbols(y) == True
assert expr.has_any_symbols(z) == True
assert expr.has_any_symbols(t) == True
assert expr.has_any_symbols(x, y, z, t) == True
assert expr.has_any_symbols(x, y, z, t, u) == True
from sympy.physics.units import m, s
assert (x*m/s).has_any_symbols(x) == True
assert (x*m/s).has_all_symbols(x) == True
assert (x*m/s).has_any_symbols(y, z) == False
assert (x*m/s).has_all_symbols(x, y) == False
poly = Poly(x**2 + x*y*sin(z), x, y, t)
assert poly.has_any_symbols(x) == True
assert poly.has_any_symbols(x, y, z) == True
assert poly.has_any_symbols(x, y, z, t) == True
assert poly.has_all_symbols(x, y, z) == True
assert poly.has_all_symbols(x, y, z, t) == False
开发者ID:KevinGoodsell,项目名称:sympy,代码行数:39,代码来源:test_basic.py
示例6: test_has_all
def test_has_all():
x,y,z,t,u = symbols('xyztu')
u = symbols('u')
i = Integer(4400)
assert i.has(x, all=True) is False
assert (i*x**i).has(x, all=True)
assert (i*y**i).has(x, all=True) is False
expr = x**2*y + sin(2**t + log(z))
assert expr.has(y, z, t, all=True)
assert expr.has(x, z, t, all=True)
assert expr.has(x, y, t, all=True)
assert expr.has(x, y, z, all=True)
assert expr.has(y, u, t, all=True) is False
assert expr.has(x, z, u, all=True) is False
assert expr.has(u, y, z, all=True) is False
assert expr.has(x, y, z, t, all=True)
assert expr.has(x, y, z, t, u, all=True) is False
from sympy.physics.units import m, s
assert (x*m/s).has(x, all=True)
assert (x*m/s).has(x, y, all=True) is False
poly = Poly(x**2 + x*y*sin(z), x, y, t)
assert poly.has(x, y, z, all=True)
assert poly.has(x, y, z, t, all=True) is False
f = FockState((x, y))
assert f.has(x, y, all=True)
assert f.has(x, y, z, all=True) is False
开发者ID:rainly,项目名称:sympy,代码行数:38,代码来源:test_expr.py
示例7: test_has_all_symbols
def test_has_all_symbols():
x,y,z,t,u = symbols('xyztu')
i = Integer(4400)
assert i.has_all_symbols(x) == False
assert (i*x**i).has_all_symbols(x) == True
assert (i*y**i).has_all_symbols(x) == False
expr = x**2*y + sin(2**t + log(z))
assert expr.has_all_symbols(y, z, t) == True
assert expr.has_all_symbols(x, z, t) == True
assert expr.has_all_symbols(x, y, t) == True
assert expr.has_all_symbols(x, y, z) == True
assert expr.has_all_symbols(y, u, t) == False
assert expr.has_all_symbols(x, z, u) == False
assert expr.has_all_symbols(u, y, z) == False
assert expr.has_all_symbols(x, y, z, t) == True
assert expr.has_all_symbols(x, y, z, t, u) == False
开发者ID:KevinGoodsell,项目名称:sympy,代码行数:23,代码来源:test_basic.py
注:本文中的sympy.Integer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论