本文整理汇总了Python中sympy.Q.positive方法的典型用法代码示例。如果您正苦于以下问题:Python Q.positive方法的具体用法?Python Q.positive怎么用?Python Q.positive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.Q
的用法示例。
在下文中一共展示了Q.positive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_CheckOldAssump
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive [as 别名]
def test_CheckOldAssump():
# TODO: Make these tests more complete
class Test1(Expr):
def _eval_is_positive(self):
return True
def _eval_is_negative(self):
return False
class Test2(Expr):
def _eval_is_finite(self):
return True
def _eval_is_positive(self):
return True
def _eval_is_negative(self):
return False
t1 = Test1()
t2 = Test2()
# We can't say if it's positive or negative in the old assumptions without
# bounded. Remember, True means "no new knowledge", and
# Q.positive(t2) means "t2 is positive."
assert CheckOldAssump(Q.positive(t1)) == True
assert CheckOldAssump(Q.negative(t1)) == ~Q.negative(t1)
assert CheckOldAssump(Q.positive(t2)) == Q.positive(t2)
assert CheckOldAssump(Q.negative(t2)) == ~Q.negative(t2)
示例2: test_pow
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive [as 别名]
def test_pow():
assert refine((-1) ** x, Q.even(x)) == 1
assert refine((-1) ** x, Q.odd(x)) == -1
assert refine((-2) ** x, Q.even(x)) == 2 ** x
# nested powers
assert refine(sqrt(x ** 2)) != Abs(x)
assert refine(sqrt(x ** 2), Q.complex(x)) != Abs(x)
assert refine(sqrt(x ** 2), Q.real(x)) == Abs(x)
assert refine(sqrt(x ** 2), Q.positive(x)) == x
assert refine((x ** 3) ** (S(1) / 3)) != x
assert refine((x ** 3) ** (S(1) / 3), Q.real(x)) != x
assert refine((x ** 3) ** (S(1) / 3), Q.positive(x)) == x
assert refine(sqrt(1 / x), Q.real(x)) != 1 / sqrt(x)
assert refine(sqrt(1 / x), Q.positive(x)) == 1 / sqrt(x)
# powers of (-1)
assert refine((-1) ** (x + y), Q.even(x)) == (-1) ** y
assert refine((-1) ** (x + y + z), Q.odd(x) & Q.odd(z)) == (-1) ** y
assert refine((-1) ** (x + y + 1), Q.odd(x)) == (-1) ** y
assert refine((-1) ** (x + y + 2), Q.odd(x)) == (-1) ** (y + 1)
assert refine((-1) ** (x + 3)) == (-1) ** (x + 1)
assert refine((-1) ** ((-1) ** x / 2 - S.Half), Q.integer(x)) == (-1) ** x
assert refine((-1) ** ((-1) ** x / 2 + S.Half), Q.integer(x)) == (-1) ** (x + 1)
assert refine((-1) ** ((-1) ** x / 2 + 5 * S.Half), Q.integer(x)) == (-1) ** (x + 1)
assert refine((-1) ** ((-1) ** x / 2 - 7 * S.Half), Q.integer(x)) == (-1) ** (x + 1)
assert refine((-1) ** ((-1) ** x / 2 - 9 * S.Half), Q.integer(x)) == (-1) ** x
# powers of Abs
assert refine(Abs(x) ** 2, Q.real(x)) == x ** 2
assert refine(Abs(x) ** 3, Q.real(x)) == Abs(x) ** 3
assert refine(Abs(x) ** 2) == Abs(x) ** 2
示例3: test_pow
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive [as 别名]
def test_pow():
x, y, z = symbols('x,y,z')
assert refine((-1)**x, Q.even(x)) == 1
assert refine((-1)**x, Q.odd(x)) == -1
assert refine((-2)**x, Q.even(x)) == 2**x
# nested powers
assert refine(sqrt(x**2)) != Abs(x)
assert refine(sqrt(x**2), Q.complex(x)) != Abs(x)
assert refine(sqrt(x**2), Q.real(x)) == Abs(x)
assert refine(sqrt(x**2), Q.positive(x)) == x
assert refine((x**3)**(S(1)/3)) != x
assert refine((x**3)**(S(1)/3), Q.real(x)) != x
assert refine((x**3)**(S(1)/3), Q.positive(x)) == x
assert refine(sqrt(1/x), Q.real(x)) != 1/sqrt(x)
assert refine(sqrt(1/x), Q.positive(x)) == 1/sqrt(x)
# powers of (-1)
assert refine((-1)**(x+y), Q.even(x)) == (-1)**y
assert refine((-1)**(x+y+z), Q.odd(x) & Q.odd(z))==(-1)**y
assert refine((-1)**(x+y+1), Q.odd(x))==(-1)**y
assert refine((-1)**(x+y+2), Q.odd(x))==(-1)**(y+1)
assert refine((-1)**(x+3)) == (-1)**(x+1)
示例4: test_Abs
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive [as 别名]
def test_Abs():
assert refine(Abs(x), Q.positive(x)) == x
assert refine(1 + Abs(x), Q.positive(x)) == 1 + x
assert refine(Abs(x), Q.negative(x)) == -x
assert refine(1 + Abs(x), Q.negative(x)) == 1 - x
assert refine(Abs(x ** 2)) != x ** 2
assert refine(Abs(x ** 2), Q.real(x)) == x ** 2
示例5: test_refine_issue_12724
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive [as 别名]
def test_refine_issue_12724():
expr1 = refine(Abs(x * y), Q.positive(x))
expr2 = refine(Abs(x * y * z), Q.positive(x))
assert expr1 == x * Abs(y)
assert expr2 == x * Abs(y * z)
y1 = Symbol('y1', real = True)
expr3 = refine(Abs(x * y1**2 * z), Q.positive(x))
assert expr3 == x * y1**2 * Abs(z)
示例6: test_ExactlyOneArg
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive [as 别名]
def test_ExactlyOneArg():
a = ExactlyOneArg(Q.zero)
b = ExactlyOneArg(Q.positive | Q.negative)
assert a.rcall(x*y) == Or(Q.zero(x) & ~Q.zero(y), Q.zero(y) & ~Q.zero(x))
assert a.rcall(x*y*z) == Or(Q.zero(x) & ~Q.zero(y) & ~Q.zero(z), Q.zero(y)
& ~Q.zero(x) & ~Q.zero(z), Q.zero(z) & ~Q.zero(x) & ~Q.zero(y))
assert b.rcall(x*y) == Or((Q.positive(x) | Q.negative(x)) &
~(Q.positive(y) | Q.negative(y)), (Q.positive(y) | Q.negative(y)) &
~(Q.positive(x) | Q.negative(x)))
示例7: test_atan2
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive [as 别名]
def test_atan2():
assert refine(atan2(y, x), Q.real(y) & Q.positive(x)) == atan(y/x)
assert refine(atan2(y, x), Q.negative(y) & Q.positive(x)) == atan(y/x)
assert refine(atan2(y, x), Q.negative(y) & Q.negative(x)) == atan(y/x) - pi
assert refine(atan2(y, x), Q.positive(y) & Q.negative(x)) == atan(y/x) + pi
assert refine(atan2(y, x), Q.zero(y) & Q.negative(x)) == pi
assert refine(atan2(y, x), Q.positive(y) & Q.zero(x)) == pi/2
assert refine(atan2(y, x), Q.negative(y) & Q.zero(x)) == -pi/2
assert refine(atan2(y, x), Q.zero(y) & Q.zero(x)) == nan
示例8: test_pos_neg
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive [as 别名]
def test_pos_neg():
assert satask(~Q.positive(x), Q.negative(x)) is True
assert satask(~Q.negative(x), Q.positive(x)) is True
assert satask(Q.positive(x + y), Q.positive(x) & Q.positive(y)) is True
assert satask(Q.negative(x + y), Q.negative(x) & Q.negative(y)) is True
assert satask(Q.positive(x + y), Q.negative(x) & Q.negative(y)) is False
assert satask(Q.negative(x + y), Q.positive(x) & Q.positive(y)) is False
示例9: test_zero_pow
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive [as 别名]
def test_zero_pow():
assert satask(Q.zero(x**y), Q.zero(x) & Q.positive(y)) is True
assert satask(Q.zero(x**y), Q.nonzero(x) & Q.zero(y)) is False
assert satask(Q.zero(x), Q.zero(x**y)) is True
assert satask(Q.zero(x**y), Q.zero(x)) is None
示例10: test_abs
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive [as 别名]
def test_abs():
assert satask(Q.nonnegative(abs(x))) is True
assert satask(Q.positive(abs(x)), ~Q.zero(x)) is True
assert satask(Q.zero(x), ~Q.zero(abs(x))) is False
assert satask(Q.zero(x), Q.zero(abs(x))) is True
assert satask(Q.nonzero(x), ~Q.zero(abs(x))) is None # x could be complex
assert satask(Q.zero(abs(x)), Q.zero(x)) is True
示例11: test_pow1
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive [as 别名]
def test_pow1():
assert refine((-1)**x, Q.even(x)) == 1
assert refine((-1)**x, Q.odd(x)) == -1
assert refine((-2)**x, Q.even(x)) == 2**x
# nested powers
assert refine(sqrt(x**2)) != Abs(x)
assert refine(sqrt(x**2), Q.complex(x)) != Abs(x)
assert refine(sqrt(x**2), Q.real(x)) == Abs(x)
assert refine(sqrt(x**2), Q.positive(x)) == x
assert refine((x**3)**(S(1)/3)) != x
assert refine((x**3)**(S(1)/3), Q.real(x)) != x
assert refine((x**3)**(S(1)/3), Q.positive(x)) == x
assert refine(sqrt(1/x), Q.real(x)) != 1/sqrt(x)
assert refine(sqrt(1/x), Q.positive(x)) == 1/sqrt(x)
示例12: test_old_assump
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive [as 别名]
def test_old_assump():
assert satask(Q.positive(1)) is True
assert satask(Q.positive(-1)) is False
assert satask(Q.positive(0)) is False
assert satask(Q.positive(I)) is False
assert satask(Q.positive(pi)) is True
assert satask(Q.negative(1)) is False
assert satask(Q.negative(-1)) is True
assert satask(Q.negative(0)) is False
assert satask(Q.negative(I)) is False
assert satask(Q.negative(pi)) is False
assert satask(Q.zero(1)) is False
assert satask(Q.zero(-1)) is False
assert satask(Q.zero(0)) is True
assert satask(Q.zero(I)) is False
assert satask(Q.zero(pi)) is False
assert satask(Q.nonzero(1)) is True
assert satask(Q.nonzero(-1)) is True
assert satask(Q.nonzero(0)) is False
assert satask(Q.nonzero(I)) is False
assert satask(Q.nonzero(pi)) is True
assert satask(Q.nonpositive(1)) is False
assert satask(Q.nonpositive(-1)) is True
assert satask(Q.nonpositive(0)) is True
assert satask(Q.nonpositive(I)) is False
assert satask(Q.nonpositive(pi)) is False
assert satask(Q.nonnegative(1)) is True
assert satask(Q.nonnegative(-1)) is False
assert satask(Q.nonnegative(0)) is True
assert satask(Q.nonnegative(I)) is False
assert satask(Q.nonnegative(pi)) is True
示例13: test_positive_definite
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive [as 别名]
def test_positive_definite():
assert ask(Q.positive_definite(X), Q.positive_definite(X))
assert ask(Q.positive_definite(X.T), Q.positive_definite(X)) is True
assert ask(Q.positive_definite(X.I), Q.positive_definite(X)) is True
assert ask(Q.positive_definite(Y)) is False
assert ask(Q.positive_definite(X)) is None
assert ask(Q.positive_definite(X*Z*X),
Q.positive_definite(X) & Q.positive_definite(Z)) is True
assert ask(Q.positive_definite(X), Q.orthogonal(X))
assert ask(Q.positive_definite(Y.T*X*Y),
Q.positive_definite(X) & Q.fullrank(Y)) is True
assert not ask(Q.positive_definite(Y.T*X*Y), Q.positive_definite(X))
assert ask(Q.positive_definite(Identity(3))) is True
assert ask(Q.positive_definite(ZeroMatrix(3, 3))) is False
assert ask(Q.positive_definite(X + Z), Q.positive_definite(X) &
Q.positive_definite(Z)) is True
assert not ask(Q.positive_definite(-X), Q.positive_definite(X))
assert ask(Q.positive(X[1, 1]), Q.positive_definite(X))
示例14: test_call
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive [as 别名]
def test_call():
x, y = symbols('x y')
# See the long history of this in issues 5026 and 5105.
raises(TypeError, lambda: sin(x)({ x : 1, sin(x) : 2}))
raises(TypeError, lambda: sin(x)(1))
# No effect as there are no callables
assert sin(x).rcall(1) == sin(x)
assert (1 + sin(x)).rcall(1) == 1 + sin(x)
# Effect in the pressence of callables
l = Lambda(x, 2*x)
assert (l + x).rcall(y) == 2*y + x
assert (x**l).rcall(2) == x**4
# TODO UndefinedFunction does not subclass Expr
#f = Function('f')
#assert (2*f)(x) == 2*f(x)
assert (Q.real & Q.positive).rcall(x) == Q.real(x) & Q.positive(x)
示例15: test_satask
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive [as 别名]
def test_satask():
# No relevant facts
assert satask(Q.real(x), Q.real(x)) is True
assert satask(Q.real(x), ~Q.real(x)) is False
assert satask(Q.real(x)) is None
assert satask(Q.real(x), Q.positive(x)) is True
assert satask(Q.positive(x), Q.real(x)) is None
assert satask(Q.real(x), ~Q.positive(x)) is None
assert satask(Q.positive(x), ~Q.real(x)) is False
raises(ValueError, lambda: satask(Q.real(x), Q.real(x) & ~Q.real(x)))
with assuming(Q.positive(x)):
assert satask(Q.real(x)) is True
assert satask(~Q.positive(x)) is False
raises(ValueError, lambda: satask(Q.real(x), ~Q.positive(x)))
assert satask(Q.zero(x), Q.nonzero(x)) is False
assert satask(Q.positive(x), Q.zero(x)) is False
assert satask(Q.real(x), Q.zero(x)) is True
assert satask(Q.zero(x), Q.zero(x*y)) is None
assert satask(Q.zero(x*y), Q.zero(x))