本文整理汇总了Python中sympy.Q.negative方法的典型用法代码示例。如果您正苦于以下问题:Python Q.negative方法的具体用法?Python Q.negative怎么用?Python Q.negative使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.Q
的用法示例。
在下文中一共展示了Q.negative方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_CheckOldAssump
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import negative [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_UnevaluatedOnFree
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import negative [as 别名]
def test_UnevaluatedOnFree():
a = UnevaluatedOnFree(Q.positive)
b = UnevaluatedOnFree(Q.positive | Q.negative)
c = UnevaluatedOnFree(Q.positive & ~Q.positive) # It shouldn't do any deduction
assert a.rcall(x) == UnevaluatedOnFree(Q.positive(x))
assert b.rcall(x) == UnevaluatedOnFree(Q.positive(x) | Q.negative(x))
assert c.rcall(x) == UnevaluatedOnFree(Q.positive(x) & ~Q.positive(x))
assert a.rcall(x).expr == x
assert a.rcall(x).pred == Q.positive
assert b.rcall(x).pred == Q.positive | Q.negative
raises(ValueError, lambda: UnevaluatedOnFree(Q.positive(x) | Q.negative))
raises(ValueError, lambda: UnevaluatedOnFree(Q.positive(x) |
Q.negative(y)))
class MyUnevaluatedOnFree(UnevaluatedOnFree):
def apply(self):
return self.args[0]
a = MyUnevaluatedOnFree(Q.positive)
b = MyUnevaluatedOnFree(Q.positive | Q.negative)
c = MyUnevaluatedOnFree(Q.positive(x))
d = MyUnevaluatedOnFree(Q.positive(x) | Q.negative(x))
assert a.rcall(x) == c == Q.positive(x)
assert b.rcall(x) == d == Q.positive(x) | Q.negative(x)
raises(ValueError, lambda: MyUnevaluatedOnFree(Q.positive(x) | Q.negative(y)))
示例3: test_Abs
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import negative [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
示例4: test_ExactlyOneArg
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import negative [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)))
示例5: test_pos_neg
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import negative [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
示例6: test_issue_6746
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import negative [as 别名]
def test_issue_6746():
assert manualintegrate(y**x, x) == \
Piecewise((x, Eq(log(y), 0)), (y**x/log(y), True))
assert manualintegrate(y**(n*x), x) == \
Piecewise(
(x, Eq(n, 0)),
(Piecewise(
(n*x, Eq(log(y), 0)),
(y**(n*x)/log(y), True))/n, True))
assert manualintegrate(exp(n*x), x) == \
Piecewise((x, Eq(n, 0)), (exp(n*x)/n, True))
with assuming(~Q.zero(log(y))):
assert manualintegrate(y**x, x) == y**x/log(y)
with assuming(Q.zero(log(y))):
assert manualintegrate(y**x, x) == x
with assuming(~Q.zero(n)):
assert manualintegrate(y**(n*x), x) == \
Piecewise((n*x, Eq(log(y), 0)), (y**(n*x)/log(y), True))/n
with assuming(~Q.zero(n) & ~Q.zero(log(y))):
assert manualintegrate(y**(n*x), x) == \
y**(n*x)/(n*log(y))
with assuming(Q.negative(a)):
assert manualintegrate(1 / (a + b*x**2), x) == \
Integral(1/(a + b*x**2), x)
示例7: __new__
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import negative [as 别名]
def __new__(cls, expr, coeffs=Tuple(), alias=None, **args):
"""Construct a new algebraic number. """
expr = sympify(expr)
if isinstance(expr, (tuple, Tuple)):
minpoly, root = expr
if not minpoly.is_Poly:
minpoly = Poly(minpoly)
elif expr.is_AlgebraicNumber:
minpoly, root = expr.minpoly, expr.root
else:
minpoly, root = minimal_polynomial(
expr, args.get('gen'), polys=True), expr
dom = minpoly.get_domain()
if coeffs != Tuple():
if not isinstance(coeffs, ANP):
rep = DMP.from_sympy_list(sympify(coeffs), 0, dom)
scoeffs = Tuple(*coeffs)
else:
rep = DMP.from_list(coeffs.to_list(), 0, dom)
scoeffs = Tuple(*coeffs.to_list())
if rep.degree() >= minpoly.degree():
rep = rep.rem(minpoly.rep)
sargs = (root, scoeffs)
else:
rep = DMP.from_list([1, 0], 0, dom)
if ask(Q.negative(root)):
rep = -rep
sargs = (root, coeffs)
if alias is not None:
if not isinstance(alias, Symbol):
alias = Symbol(alias)
sargs = sargs + (alias,)
obj = Expr.__new__(cls, *sargs)
obj.rep = rep
obj.root = root
obj.alias = alias
obj.minpoly = minpoly
return obj
示例8: test_atan2
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import negative [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
示例9: test_old_assump
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import negative [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
示例10: test_AnyArgs
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import negative [as 别名]
def test_AnyArgs():
a = AnyArgs(Q.zero)
b = AnyArgs(Q.positive & Q.negative)
assert a.rcall(x*y) == Or(Q.zero(x), Q.zero(y))
assert b.rcall(x*y) == Or(Q.positive(x) & Q.negative(x), Q.positive(y) & Q.negative(y))
示例11: test_AllArgs
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import negative [as 别名]
def test_AllArgs():
a = AllArgs(Q.zero)
b = AllArgs(Q.positive | Q.negative)
assert a.rcall(x*y) == And(Q.zero(x), Q.zero(y))
assert b.rcall(x*y) == And(Q.positive(x) | Q.negative(x), Q.positive(y) | Q.negative(y))
示例12: test_pow_pos_neg
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import negative [as 别名]
def test_pow_pos_neg():
assert satask(Q.nonnegative(x**2), Q.positive(x)) is True
assert satask(Q.nonpositive(x**2), Q.positive(x)) is False
assert satask(Q.positive(x**2), Q.positive(x)) is True
assert satask(Q.negative(x**2), Q.positive(x)) is False
assert satask(Q.real(x**2), Q.positive(x)) is True
assert satask(Q.nonnegative(x**2), Q.negative(x)) is True
assert satask(Q.nonpositive(x**2), Q.negative(x)) is False
assert satask(Q.positive(x**2), Q.negative(x)) is True
assert satask(Q.negative(x**2), Q.negative(x)) is False
assert satask(Q.real(x**2), Q.negative(x)) is True
assert satask(Q.nonnegative(x**2), Q.nonnegative(x)) is True
assert satask(Q.nonpositive(x**2), Q.nonnegative(x)) is None
assert satask(Q.positive(x**2), Q.nonnegative(x)) is None
assert satask(Q.negative(x**2), Q.nonnegative(x)) is False
assert satask(Q.real(x**2), Q.nonnegative(x)) is True
assert satask(Q.nonnegative(x**2), Q.nonpositive(x)) is True
assert satask(Q.nonpositive(x**2), Q.nonpositive(x)) is None
assert satask(Q.positive(x**2), Q.nonpositive(x)) is None
assert satask(Q.negative(x**2), Q.nonpositive(x)) is False
assert satask(Q.real(x**2), Q.nonpositive(x)) is True
assert satask(Q.nonnegative(x**3), Q.positive(x)) is True
assert satask(Q.nonpositive(x**3), Q.positive(x)) is False
assert satask(Q.positive(x**3), Q.positive(x)) is True
assert satask(Q.negative(x**3), Q.positive(x)) is False
assert satask(Q.real(x**3), Q.positive(x)) is True
assert satask(Q.nonnegative(x**3), Q.negative(x)) is False
assert satask(Q.nonpositive(x**3), Q.negative(x)) is True
assert satask(Q.positive(x**3), Q.negative(x)) is False
assert satask(Q.negative(x**3), Q.negative(x)) is True
assert satask(Q.real(x**3), Q.negative(x)) is True
assert satask(Q.nonnegative(x**3), Q.nonnegative(x)) is True
assert satask(Q.nonpositive(x**3), Q.nonnegative(x)) is None
assert satask(Q.positive(x**3), Q.nonnegative(x)) is None
assert satask(Q.negative(x**3), Q.nonnegative(x)) is False
assert satask(Q.real(x**3), Q.nonnegative(x)) is True
assert satask(Q.nonnegative(x**3), Q.nonpositive(x)) is None
assert satask(Q.nonpositive(x**3), Q.nonpositive(x)) is True
assert satask(Q.positive(x**3), Q.nonpositive(x)) is False
assert satask(Q.negative(x**3), Q.nonpositive(x)) is None
assert satask(Q.real(x**3), Q.nonpositive(x)) is True
# If x is zero, x**negative is not real.
assert satask(Q.nonnegative(x**-2), Q.nonpositive(x)) is None
assert satask(Q.nonpositive(x**-2), Q.nonpositive(x)) is None
assert satask(Q.positive(x**-2), Q.nonpositive(x)) is None
assert satask(Q.negative(x**-2), Q.nonpositive(x)) is None
assert satask(Q.real(x**-2), Q.nonpositive(x)) is None
示例13: _contains
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import negative [as 别名]
def _contains(self, other):
if ask(Q.negative(other)) == False and ask(Q.integer(other)):
return True
return False