本文整理汇总了Python中sympy.assumptions.Q.algebraic方法的典型用法代码示例。如果您正苦于以下问题:Python Q.algebraic方法的具体用法?Python Q.algebraic怎么用?Python Q.algebraic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.assumptions.Q
的用法示例。
在下文中一共展示了Q.algebraic方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _construct_simple
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import algebraic [as 别名]
def _construct_simple(coeffs, opt):
"""Handle simple domains, e.g.: ZZ, QQ, RR and algebraic domains. """
result, rationals, reals, algebraics = {}, False, False, False
if opt.extension is True:
is_algebraic = lambda coeff: ask(Q.algebraic(coeff))
else:
is_algebraic = lambda coeff: False
# XXX: add support for a + b*I coefficients
for coeff in coeffs:
if coeff.is_Rational:
if not coeff.is_Integer:
rationals = True
elif coeff.is_Float:
if not algebraics:
reals = True
else:
# there are both reals and algebraics -> EX
return False
elif is_algebraic(coeff):
if not reals:
algebraics = True
else:
# there are both algebraics and reals -> EX
return False
else:
# this is a composite domain, e.g. ZZ[X], EX
return None
if algebraics:
domain, result = _construct_algebraic(coeffs, opt)
else:
if reals:
domain = RR
else:
if opt.field or rationals:
domain = QQ
else:
domain = ZZ
result = []
for coeff in coeffs:
result.append(domain.from_sympy(coeff))
return domain, result
示例2: Pow
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import algebraic [as 别名]
def Pow(expr, assumptions):
return expr.exp.is_Rational and ask(
Q.algebraic(expr.base), assumptions)
示例3: log
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import algebraic [as 别名]
def log(expr, assumptions):
x = expr.args[0]
if ask(Q.algebraic(x), assumptions):
return ask(~Q.nonzero(x - 1), assumptions)
示例4: cot
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import algebraic [as 别名]
def cot(expr, assumptions):
x = expr.args[0]
if ask(Q.algebraic(x), assumptions):
return False
示例5: _is_coeff
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import algebraic [as 别名]
def _is_coeff(factor):
return ask(Q.algebraic(factor))
示例6: test_algebraic
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import algebraic [as 别名]
def test_algebraic():
x, y = symbols('x,y')
assert ask(Q.algebraic(x)) == None
assert ask(Q.algebraic(I)) == True
assert ask(Q.algebraic(2*I)) == True
assert ask(Q.algebraic(I/3)) == True
assert ask(Q.algebraic(sqrt(7))) == True
assert ask(Q.algebraic(2*sqrt(7))) == True
assert ask(Q.algebraic(sqrt(7)/3)) == True
assert ask(Q.algebraic(I*sqrt(3))) == True
assert ask(Q.algebraic(sqrt(1+I*sqrt(3)))) == True
assert ask(Q.algebraic((1+I*sqrt(3)**(S(17)/31)))) == True
assert ask(Q.algebraic((1+I*sqrt(3)**(S(17)/pi)))) == False
assert ask(Q.algebraic(sin(7))) == None
assert ask(Q.algebraic(sqrt(sin(7)))) == None
assert ask(Q.algebraic(sqrt(y+I*sqrt(7)))) == None
assert ask(Q.algebraic(oo)) == False
assert ask(Q.algebraic(-oo)) == False
assert ask(Q.algebraic(2.47)) == False