本文整理汇总了Python中sympy.assumptions.Q.rational方法的典型用法代码示例。如果您正苦于以下问题:Python Q.rational方法的具体用法?Python Q.rational怎么用?Python Q.rational使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.assumptions.Q
的用法示例。
在下文中一共展示了Q.rational方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_float_1
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import rational [as 别名]
def test_float_1():
z = 1.0
assert ask(Q.commutative(z)) == True
assert ask(Q.integer(z)) == True
assert ask(Q.rational(z)) == True
assert ask(Q.real(z)) == True
assert ask(Q.complex(z)) == True
assert ask(Q.irrational(z)) == False
assert ask(Q.imaginary(z)) == False
assert ask(Q.positive(z)) == True
assert ask(Q.negative(z)) == False
assert ask(Q.even(z)) == False
assert ask(Q.odd(z)) == True
assert ask(Q.bounded(z)) == True
assert ask(Q.infinitesimal(z)) == False
assert ask(Q.prime(z)) == False
assert ask(Q.composite(z)) == True
z = 7.2123
assert ask(Q.commutative(z)) == True
assert ask(Q.integer(z)) == False
assert ask(Q.rational(z)) == True
assert ask(Q.real(z)) == True
assert ask(Q.complex(z)) == True
assert ask(Q.irrational(z)) == False
assert ask(Q.imaginary(z)) == False
assert ask(Q.positive(z)) == True
assert ask(Q.negative(z)) == False
assert ask(Q.even(z)) == False
assert ask(Q.odd(z)) == False
assert ask(Q.bounded(z)) == True
assert ask(Q.infinitesimal(z)) == False
assert ask(Q.prime(z)) == False
assert ask(Q.composite(z)) == False
示例2: Pow
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import rational [as 别名]
def Pow(expr, assumptions):
"""
Rational ** Integer -> Rational
Irrational ** Rational -> Irrational
Rational ** Irrational -> ?
"""
if ask(Q.integer(expr.exp), assumptions):
return ask(Q.rational(expr.base), assumptions)
elif ask(Q.rational(expr.exp), assumptions):
if ask(Q.prime(expr.base), assumptions):
return False
示例3: test_I
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import rational [as 别名]
def test_I():
I = S.ImaginaryUnit
z = I
assert ask(Q.commutative(z)) == True
assert ask(Q.integer(z)) == False
assert ask(Q.rational(z)) == False
assert ask(Q.real(z)) == False
assert ask(Q.complex(z)) == True
assert ask(Q.irrational(z)) == False
assert ask(Q.imaginary(z)) == True
assert ask(Q.positive(z)) == False
assert ask(Q.negative(z)) == False
assert ask(Q.even(z)) == False
assert ask(Q.odd(z)) == False
assert ask(Q.bounded(z)) == True
assert ask(Q.infinitesimal(z)) == False
assert ask(Q.prime(z)) == False
assert ask(Q.composite(z)) == False
z = 1 + I
assert ask(Q.commutative(z)) == True
assert ask(Q.integer(z)) == False
assert ask(Q.rational(z)) == False
assert ask(Q.real(z)) == False
assert ask(Q.complex(z)) == True
assert ask(Q.irrational(z)) == False
assert ask(Q.imaginary(z)) == False
assert ask(Q.positive(z)) == False
assert ask(Q.negative(z)) == False
assert ask(Q.even(z)) == False
assert ask(Q.odd(z)) == False
assert ask(Q.bounded(z)) == True
assert ask(Q.infinitesimal(z)) == False
assert ask(Q.prime(z)) == False
assert ask(Q.composite(z)) == False
z = I*(1+I)
assert ask(Q.commutative(z)) == True
assert ask(Q.integer(z)) == False
assert ask(Q.rational(z)) == False
assert ask(Q.real(z)) == False
assert ask(Q.complex(z)) == True
assert ask(Q.irrational(z)) == False
assert ask(Q.imaginary(z)) == False
assert ask(Q.positive(z)) == False
assert ask(Q.negative(z)) == False
assert ask(Q.even(z)) == False
assert ask(Q.odd(z)) == False
assert ask(Q.bounded(z)) == True
assert ask(Q.infinitesimal(z)) == False
assert ask(Q.prime(z)) == False
assert ask(Q.composite(z)) == False
示例4: Basic
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import rational [as 别名]
def Basic(expr, assumptions):
_real = ask(Q.real(expr), assumptions)
if _real:
_rational = ask(Q.rational(expr), assumptions)
if _rational is None: return None
return not _rational
else: return _real
示例5: test_odd
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import rational [as 别名]
def test_odd():
x, y, z, t = symbols('x,y,z,t')
assert ask(Q.odd(x)) == None
assert ask(Q.odd(x), Q.odd(x)) == True
assert ask(Q.odd(x), Q.integer(x)) == None
assert ask(Q.odd(x), ~Q.integer(x)) == False
assert ask(Q.odd(x), Q.rational(x)) == None
assert ask(Q.odd(x), Q.positive(x)) == None
assert ask(Q.odd(-x), Q.odd(x)) == True
assert ask(Q.odd(2*x)) == None
assert ask(Q.odd(2*x), Q.integer(x)) == False
assert ask(Q.odd(2*x), Q.odd(x)) == False
assert ask(Q.odd(2*x), Q.irrational(x)) == False
assert ask(Q.odd(2*x), ~Q.integer(x)) == None
assert ask(Q.odd(3*x), Q.integer(x)) == None
assert ask(Q.odd(x/3), Q.odd(x)) == None
assert ask(Q.odd(x/3), Q.even(x)) == None
assert ask(Q.odd(x+1), Q.even(x)) == True
assert ask(Q.odd(x+2), Q.even(x)) == False
assert ask(Q.odd(x+2), Q.odd(x)) == True
assert ask(Q.odd(3-x), Q.odd(x)) == False
assert ask(Q.odd(3-x), Q.even(x)) == True
assert ask(Q.odd(3+x), Q.odd(x)) == False
assert ask(Q.odd(3+x), Q.even(x)) == True
assert ask(Q.odd(x+y), Q.odd(x) & Q.odd(y)) == False
assert ask(Q.odd(x+y), Q.odd(x) & Q.even(y)) == True
assert ask(Q.odd(x-y), Q.even(x) & Q.odd(y)) == True
assert ask(Q.odd(x-y), Q.odd(x) & Q.odd(y)) == False
assert ask(Q.odd(x+y+z), Q.odd(x) & Q.odd(y) & Q.even(z)) == False
assert ask(Q.odd(x+y+z+t),
Q.odd(x) & Q.odd(y) & Q.even(z) & Q.integer(t)) == None
assert ask(Q.odd(2*x + 1), Q.integer(x)) == True
assert ask(Q.odd(2*x + y), Q.integer(x) & Q.odd(y)) == True
assert ask(Q.odd(2*x + y), Q.integer(x) & Q.even(y)) == False
assert ask(Q.odd(2*x + y), Q.integer(x) & Q.integer(y)) == None
assert ask(Q.odd(x*y), Q.odd(x) & Q.even(y)) == False
assert ask(Q.odd(x*y), Q.odd(x) & Q.odd(y)) == True
assert ask(Q.odd(2*x*y), Q.rational(x) & Q.rational(x)) == None
assert ask(Q.odd(2*x*y), Q.irrational(x) & Q.irrational(x)) == None
assert ask(Q.odd(Abs(x)), Q.odd(x)) == True
示例6: test_even
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import rational [as 别名]
def test_even():
x, y, z, t = symbols('x,y,z,t')
assert ask(Q.even(x)) == None
assert ask(Q.even(x), Q.integer(x)) == None
assert ask(Q.even(x), ~Q.integer(x)) == False
assert ask(Q.even(x), Q.rational(x)) == None
assert ask(Q.even(x), Q.positive(x)) == None
assert ask(Q.even(2*x)) == None
assert ask(Q.even(2*x), Q.integer(x)) == True
assert ask(Q.even(2*x), Q.even(x)) == True
assert ask(Q.even(2*x), Q.irrational(x)) == False
assert ask(Q.even(2*x), Q.odd(x)) == True
assert ask(Q.even(2*x), ~Q.integer(x)) == None
assert ask(Q.even(3*x), Q.integer(x)) == None
assert ask(Q.even(3*x), Q.even(x)) == True
assert ask(Q.even(3*x), Q.odd(x)) == False
assert ask(Q.even(x+1), Q.odd(x)) == True
assert ask(Q.even(x+1), Q.even(x)) == False
assert ask(Q.even(x+2), Q.odd(x)) == False
assert ask(Q.even(x+2), Q.even(x)) == True
assert ask(Q.even(7-x), Q.odd(x)) == True
assert ask(Q.even(7+x), Q.odd(x)) == True
assert ask(Q.even(x+y), Q.odd(x) & Q.odd(y)) == True
assert ask(Q.even(x+y), Q.odd(x) & Q.even(y)) == False
assert ask(Q.even(x+y), Q.even(x) & Q.even(y)) == True
assert ask(Q.even(2*x + 1), Q.integer(x)) == False
assert ask(Q.even(2*x*y), Q.rational(x) & Q.rational(x)) == None
assert ask(Q.even(2*x*y), Q.irrational(x) & Q.irrational(x)) == None
assert ask(Q.even(x+y+z), Q.odd(x) & Q.odd(y) & Q.even(z)) == True
assert ask(Q.even(x+y+z+t),
Q.odd(x) & Q.odd(y) & Q.even(z) & Q.integer(t)) == None
assert ask(Q.even(Abs(x)), Q.even(x)) == True
assert ask(Q.even(Abs(x)), ~Q.even(x)) == None
assert ask(Q.even(re(x)), Q.even(x)) == True
assert ask(Q.even(re(x)), ~Q.even(x)) == None
assert ask(Q.even(im(x)), Q.even(x)) == True
assert ask(Q.even(im(x)), Q.real(x)) == True
示例7: Pow
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import rational [as 别名]
def Pow(expr, assumptions):
"""
Imaginary**Odd -> Imaginary
Imaginary**Even -> Real
b**Imaginary -> !Imaginary if exponent is an integer multiple of I*pi/log(b)
Imaginary**Real -> ?
Positive**Real -> Real
Negative**Integer -> Real
Negative**(Integer/2) -> Imaginary
Negative**Real -> not Imaginary if exponent is not Rational
"""
if expr.is_number:
return AskImaginaryHandler._number(expr, assumptions)
if expr.base.func == exp:
if ask(Q.imaginary(expr.base.args[0]), assumptions):
if ask(Q.imaginary(expr.exp), assumptions):
return False
i = expr.base.args[0]/I/pi
if ask(Q.integer(2*i), assumptions):
return ask(Q.imaginary(((-1)**i)**expr.exp), assumptions)
if ask(Q.imaginary(expr.base), assumptions):
if ask(Q.integer(expr.exp), assumptions):
odd = ask(Q.odd(expr.exp), assumptions)
if odd is not None:
return odd
return
if ask(Q.imaginary(expr.exp), assumptions):
imlog = ask(Q.imaginary(log(expr.base)), assumptions)
if imlog is not None:
return False # I**i -> real; (2*I)**i -> complex ==> not imaginary
if ask(Q.real(expr.base) & Q.real(expr.exp), assumptions):
if ask(Q.positive(expr.base), assumptions):
return False
else:
rat = ask(Q.rational(expr.exp), assumptions)
if not rat:
return rat
if ask(Q.integer(expr.exp), assumptions):
return False
else:
half = ask(Q.integer(2*expr.exp), assumptions)
if half:
return ask(Q.negative(expr.base), assumptions)
return half
示例8: test_E
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import rational [as 别名]
def test_E():
z = S.Exp1
assert ask(Q.commutative(z)) == True
assert ask(Q.integer(z)) == False
assert ask(Q.rational(z)) == False
assert ask(Q.real(z)) == True
assert ask(Q.complex(z)) == True
assert ask(Q.irrational(z)) == True
assert ask(Q.imaginary(z)) == False
assert ask(Q.positive(z)) == True
assert ask(Q.negative(z)) == False
assert ask(Q.even(z)) == False
assert ask(Q.odd(z)) == False
assert ask(Q.bounded(z)) == True
assert ask(Q.infinitesimal(z)) == False
assert ask(Q.prime(z)) == False
assert ask(Q.composite(z)) == False
示例9: test_zero_0
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import rational [as 别名]
def test_zero_0():
z = Integer(0)
assert ask(Q.nonzero(z)) == False
assert ask(Q.commutative(z)) == True
assert ask(Q.integer(z)) == True
assert ask(Q.rational(z)) == True
assert ask(Q.real(z)) == True
assert ask(Q.complex(z)) == True
assert ask(Q.imaginary(z)) == False
assert ask(Q.positive(z)) == False
assert ask(Q.negative(z)) == False
assert ask(Q.even(z)) == True
assert ask(Q.odd(z)) == False
assert ask(Q.bounded(z)) == True
assert ask(Q.infinitesimal(z)) == True
assert ask(Q.prime(z)) == False
assert ask(Q.composite(z)) == False
示例10: test_Rational_number
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import rational [as 别名]
def test_Rational_number():
r = Rational(3,4)
assert ask(Q.commutative(r)) == True
assert ask(Q.integer(r)) == False
assert ask(Q.rational(r)) == True
assert ask(Q.real(r)) == True
assert ask(Q.complex(r)) == True
assert ask(Q.irrational(r)) == False
assert ask(Q.imaginary(r)) == False
assert ask(Q.positive(r)) == True
assert ask(Q.negative(r)) == False
assert ask(Q.even(r)) == False
assert ask(Q.odd(r)) == False
assert ask(Q.bounded(r)) == True
assert ask(Q.infinitesimal(r)) == False
assert ask(Q.prime(r)) == False
assert ask(Q.composite(r)) == False
r = Rational(1,4)
assert ask(Q.positive(r)) == True
assert ask(Q.negative(r)) == False
r = Rational(5,4)
assert ask(Q.negative(r)) == False
assert ask(Q.positive(r)) == True
r = Rational(5,3)
assert ask(Q.positive(r)) == True
assert ask(Q.negative(r)) == False
r = Rational(-3,4)
assert ask(Q.positive(r)) == False
assert ask(Q.negative(r)) == True
r = Rational(-1,4)
assert ask(Q.positive(r)) == False
assert ask(Q.negative(r)) == True
r = Rational(-5,4)
assert ask(Q.negative(r)) == True
assert ask(Q.positive(r)) == False
r = Rational(-5,3)
assert ask(Q.positive(r)) == False
assert ask(Q.negative(r)) == True
示例11: Pow
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import rational [as 别名]
def Pow(expr, assumptions):
"""
Imaginary**integer/odd -> Imaginary
Imaginary**integer/even -> Real if integer % 2 == 0
b**Imaginary -> !Imaginary if exponent is an integer multiple of I*pi/log(b)
Imaginary**Real -> ?
Negative**even root -> Imaginary
Negative**odd root -> Real
Negative**Real -> Imaginary
Real**Integer -> Real
Real**Positive -> Real
"""
if expr.is_number:
return AskImaginaryHandler._number(expr, assumptions)
if expr.base.func == C.exp:
if ask(Q.imaginary(expr.base.args[0]), assumptions):
if ask(Q.imaginary(expr.exp), assumptions):
return False
i = expr.base.args[0]/I/pi
if ask(Q.integer(2*i), assumptions):
return ask(Q.imaginary(((-1)**i)**expr.exp), assumptions)
if ask(Q.imaginary(expr.base), assumptions):
if ask(Q.integer(expr.exp), assumptions):
odd = ask(Q.odd(expr.exp), assumptions)
if odd is not None:
return odd
return
if ask(Q.imaginary(expr.exp), assumptions):
imlog = ask(Q.imaginary(C.log(expr.base)), assumptions)
if imlog is not None:
return False # I**i -> real; (2*I)**i -> complex ==> not imaginary
if ask(Q.real(expr.base), assumptions):
if ask(Q.real(expr.exp), assumptions):
if ask(Q.rational(expr.exp) & Q.even(denom(expr.exp)), assumptions):
return ask(Q.negative(expr.base), assumptions)
elif ask(Q.integer(expr.exp), assumptions):
return False
elif ask(Q.positive(expr.base), assumptions):
return False
elif ask(Q.negative(expr.base), assumptions):
return True
示例12: test_infinity
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import rational [as 别名]
def test_infinity():
oo = S.Infinity
assert ask(Q.commutative(oo)) == True
assert ask(Q.integer(oo)) == False
assert ask(Q.rational(oo)) == False
assert ask(Q.real(oo)) == False
assert ask(Q.extended_real(oo)) == True
assert ask(Q.complex(oo)) == False
assert ask(Q.irrational(oo)) == False
assert ask(Q.imaginary(oo)) == False
assert ask(Q.positive(oo)) == True
assert ask(Q.negative(oo)) == False
assert ask(Q.even(oo)) == False
assert ask(Q.odd(oo)) == False
assert ask(Q.bounded(oo)) == False
assert ask(Q.infinitesimal(oo)) == False
assert ask(Q.prime(oo)) == False
assert ask(Q.composite(oo)) == False
示例13: test_neg_infinity
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import rational [as 别名]
def test_neg_infinity():
mm = S.NegativeInfinity
assert ask(Q.commutative(mm)) == True
assert ask(Q.integer(mm)) == False
assert ask(Q.rational(mm)) == False
assert ask(Q.real(mm)) == False
assert ask(Q.extended_real(mm)) == True
assert ask(Q.complex(mm)) == False
assert ask(Q.irrational(mm)) == False
assert ask(Q.imaginary(mm)) == False
assert ask(Q.positive(mm)) == False
assert ask(Q.negative(mm)) == True
assert ask(Q.even(mm)) == False
assert ask(Q.odd(mm)) == False
assert ask(Q.bounded(mm)) == False
assert ask(Q.infinitesimal(mm)) == False
assert ask(Q.prime(mm)) == False
assert ask(Q.composite(mm)) == False
示例14: test_nan
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import rational [as 别名]
def test_nan():
nan = S.NaN
assert ask(Q.commutative(nan)) == True
assert ask(Q.integer(nan)) == False
assert ask(Q.rational(nan)) == False
assert ask(Q.real(nan)) == False
assert ask(Q.extended_real(nan)) == False
assert ask(Q.complex(nan)) == False
assert ask(Q.irrational(nan)) == False
assert ask(Q.imaginary(nan)) == False
assert ask(Q.positive(nan)) == False
assert ask(Q.nonzero(nan)) == True
assert ask(Q.even(nan)) == False
assert ask(Q.odd(nan)) == False
assert ask(Q.bounded(nan)) == False
assert ask(Q.infinitesimal(nan)) == False
assert ask(Q.prime(nan)) == False
assert ask(Q.composite(nan)) == False
示例15: test_integer
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import rational [as 别名]
def test_integer():
x = symbols('x')
assert ask(Q.integer(x)) == None
assert ask(Q.integer(x), Q.integer(x)) == True
assert ask(Q.integer(x), ~Q.integer(x)) == False
assert ask(Q.integer(x), ~Q.real(x)) == False
assert ask(Q.integer(x), ~Q.positive(x)) == None
assert ask(Q.integer(x), Q.even(x) | Q.odd(x)) == True
assert ask(Q.integer(2*x), Q.integer(x)) == True
assert ask(Q.integer(2*x), Q.even(x)) == True
assert ask(Q.integer(2*x), Q.prime(x)) == True
assert ask(Q.integer(2*x), Q.rational(x)) == None
assert ask(Q.integer(2*x), Q.real(x)) == None
assert ask(Q.integer(sqrt(2)*x), Q.integer(x)) == False
assert ask(Q.integer(x/2), Q.odd(x)) == False
assert ask(Q.integer(x/2), Q.even(x)) == True
assert ask(Q.integer(x/3), Q.odd(x)) == None
assert ask(Q.integer(x/3), Q.even(x)) == None