本文整理汇总了Python中sympy.assumptions.Q.bounded方法的典型用法代码示例。如果您正苦于以下问题:Python Q.bounded方法的具体用法?Python Q.bounded怎么用?Python Q.bounded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.assumptions.Q
的用法示例。
在下文中一共展示了Q.bounded方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_float_1
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import bounded [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: test_I
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import bounded [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
示例3: Mul
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import bounded [as 别名]
def Mul(expr, assumptions):
"""
Return True if expr is bounded, False if not and None if unknown.
TRUTH TABLE
B U ?
s /s
+---+---+---+---+
B | B | U | ? | legend:
+---+---+---+---+ B = Bounded
U | U | U | ? | U = Unbounded
+---+---+---+ ? = unknown boundedness
? | ? | s = signed (hence nonzero)
+---+---+ /s = not signed
"""
result = True
for arg in expr.args:
_bounded = ask(Q.bounded(arg), assumptions)
if _bounded:
continue
elif _bounded is None:
if result is None:
return None
if ask(Q.nonzero(arg), assumptions) is None:
return None
if result is not False:
result = None
else:
result = False
return result
示例4: Pow
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import bounded [as 别名]
def Pow(expr, assumptions):
"""
Unbounded ** Whatever -> Unbounded
Bounded ** Unbounded -> Unbounded if base > 1
Bounded ** Unbounded -> Unbounded if base < 1
"""
base_bounded = ask(Q.bounded(expr.base), assumptions)
if not base_bounded:
return False
if ask(Q.bounded(expr.exp), assumptions):# and base_bounded:
return True
if expr.base.is_number:# and base_bounded and not exp_bounded:
# We need to implement relations for this
if abs(expr.base) > 1:
return False
return ask(~Q.negative(expr.exp), assumptions)
示例5: test_infinitesimal
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import bounded [as 别名]
def test_infinitesimal():
x, y = symbols('x,y')
assert ask(Q.infinitesimal(x)) == None
assert ask(Q.infinitesimal(x), Q.infinitesimal(x)) == True
assert ask(Q.infinitesimal(2*x), Q.infinitesimal(x)) == True
assert ask(Q.infinitesimal(x*y), Q.infinitesimal(x)) == None
assert ask(Q.infinitesimal(x*y), Q.infinitesimal(x) & Q.infinitesimal(y)) == True
assert ask(Q.infinitesimal(x*y), Q.infinitesimal(x) & Q.bounded(y)) == True
assert ask(Q.infinitesimal(x**2), Q.infinitesimal(x)) == True
示例6: Mul
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import bounded [as 别名]
def Mul(expr, assumptions):
"""
Return True if expr is bounded, False if not and None if unknown.
Truth Table:
+---+---+---+--------+
| | | | |
| | B | U | ? |
| | | | |
+---+---+---+---+----+
| | | | | |
| | | | s | /s |
| | | | | |
+---+---+---+---+----+
| | | | |
| B | B | U | ? |
| | | | |
+---+---+---+---+----+
| | | | | |
| U | | U | U | ? |
| | | | | |
+---+---+---+---+----+
| | | | |
| ? | | | ? |
| | | | |
+---+---+---+---+----+
* B = Bounded
* U = Unbounded
* ? = unknown boundedness
* s = signed (hence nonzero)
* /s = not signed
"""
result = True
for arg in expr.args:
_bounded = ask(Q.bounded(arg), assumptions)
if _bounded:
continue
elif _bounded is None:
if result is None:
return None
if ask(Q.nonzero(arg), assumptions) is None:
return None
if result is not False:
result = None
else:
result = False
return result
示例7: Pow
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import bounded [as 别名]
def Pow(expr, assumptions):
"""
Unbounded ** NonZero -> Unbounded
Bounded ** Bounded -> Bounded
Abs()<=1 ** Positive -> Bounded
Abs()>=1 ** Negative -> Bounded
Otherwise unknown
"""
base_bounded = ask(Q.bounded(expr.base), assumptions)
exp_bounded = ask(Q.bounded(expr.exp), assumptions)
if base_bounded is None and exp_bounded is None: # Common Case
return None
if base_bounded is False and ask(Q.nonzero(expr.exp), assumptions):
return False
if base_bounded and exp_bounded:
return True
if (abs(expr.base) <= 1) == True and ask(Q.positive(expr.exp), assumptions):
return True
if (abs(expr.base) >= 1) == True and ask(Q.negative(expr.exp), assumptions):
return True
if (abs(expr.base) >= 1) == True and exp_bounded is False:
return False
return None
示例8: Add
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import bounded [as 别名]
def Add(expr, assumptions):
"""
Bounded + Bounded -> Bounded
Unbounded + Bounded -> Unbounded
Unbounded + Unbounded -> ?
"""
result = True
for arg in expr.args:
_bounded = ask(Q.bounded(arg), assumptions)
if _bounded: continue
elif _bounded is None: return
elif _bounded is False:
if result: result = False
else: return
return result
示例9: Add
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import bounded [as 别名]
def Add(expr, assumptions):
"""
Return True if expr is bounded, False if not and None if unknown.
TRUTH TABLE
B U ?
+ - x + - x
+---+-----+-----+
B | B | U |? ? ?| legend:
+---+-----+-----+ B = Bounded
+ |U ? ?|U ? ?| U = Unbounded
U - |? U ?|? U ?| ? = unknown boundedness
x |? ? ?|? ? ?| + = positive sign
+-----+--+--+ - = negative sign
? |? ? ?| x = sign unknown
+--+--+
All Bounded -> True
1 Unbounded and the rest Bounded -> False
>1 Unbounded, all with same known sign -> False
Any Unknown and unknown sign -> None
Else -> None
When the signs are not the same you can have an undefined
result as in oo - oo, hence 'bounded' is also undefined.
"""
sign = -1 # sign of unknown or unbounded
result = True
for arg in expr.args:
_bounded = ask(Q.bounded(arg), assumptions)
if _bounded:
continue
s = ask(Q.positive(arg), assumptions)
# if there has been more than one sign or if the sign of this arg
# is None and Bounded is None or there was already
# an unknown sign, return None
if sign != -1 and s != sign or \
s == None and (s == _bounded or s == sign):
return None
else:
sign = s
# once False, do not change
if result is not False:
result = _bounded
return result
示例10: Add
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import bounded [as 别名]
def Add(expr, assumptions):
"""
Return True if expr is bounded, False if not and None if unknown.
TRUTH TABLE
B U ?
+ - x + - x
+---+-----+-----+
B | B | U |? ? ?| legend:
+---+-----+-----+ B = Bounded
+ |U ? ?|U ? ?| U = Unbounded
U - |? U ?|? U ?| ? = unknown boundedness
x |? ? ?|? ? ?| + = positive sign
+-----+--+--+ - = negative sign
? |? ? ?| x = sign unknown
+--+--+
All Bounded -> True
Any Unbounded and all same sign -> False
Any Unknown and unknown sign -> None
Else -> None
When the signs are not the same you can have an undefined
(hence bounded undefined) result as in oo - oo
"""
result = True
sign = -1 # not assigned yet
for arg in expr.args:
_bounded = ask(Q.bounded(arg), assumptions)
if _bounded:
continue
if result is None and _bounded is None and sign is None:
return None
if result is not False:
result = _bounded
pos = ask(Q.positive(arg), assumptions)
if sign == -1:
sign = pos
continue
if sign != pos:
return None
if sign is None and pos is None:
return None
return result
示例11: test_zero_0
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import bounded [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
示例12: test_E
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import bounded [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
示例13: test_Rational_number
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import bounded [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
示例14: test_infinity
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import bounded [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
示例15: test_neg_infinity
# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import bounded [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