# Source code for sympy.assumptions.handlers.order

"""
AskHandlers related to order relations: positive, negative, etc.
"""
from sympy.assumptions.handlers import CommonHandler

"""
This is called by ask() when key='negative'

Test that an expression is less (strict) than zero.

Examples:

>>> from sympy import ask, Q, pi
False
False

"""

@staticmethod
def _number(expr, assumptions):
if not expr.as_real_imag()[1]:
return expr.evalf() < 0
else: return False

@staticmethod
def Basic(expr, assumptions):
if expr.is_number:

@staticmethod
"""
Positive + Positive -> Positive,
Negative + Negative -> Negative
"""
if expr.is_number:
for arg in expr.args:
break
else:
# if all argument's are negative
return True

@staticmethod
def Mul(expr, assumptions):
if expr.is_number:
result = None
for arg in expr.args:
if result is None: result = False
result = not result
pass
else: return
return result

@staticmethod
[docs]    def Pow(expr, assumptions):
"""
Real ** Even -> NonNegative
Real ** Odd  -> same_as_base
NonNegative ** Positive -> NonNegative
"""
if expr.is_number:
return False
return False

@staticmethod
def ImaginaryUnit(expr, assumptions):
return False

@staticmethod
def Abs(expr, assumptions):
return False

"""
Handler for key 'zero'
Test that an expression is not identically zero
"""

@staticmethod
def Basic(expr, assumptions):
if expr.is_number:
# if there are no symbols just evalf
return expr.evalf() != 0

@staticmethod
if all(ask(Q.positive(x), assumptions) for x in expr.args) \
or all(ask(Q.negative(x), assumptions) for x in expr.args):
return True

@staticmethod
def Mul(expr, assumptions):
for arg in expr.args:
if result: continue
return result
return True

@staticmethod
def Pow(expr, assumptions):

@staticmethod
def NaN(expr, assumptions):
return True

@staticmethod
def Abs(expr, assumptions):

"""
Handler for key 'positive'
Test that an expression is greater (strict) than zero
"""

@staticmethod
def _number(expr, assumptions):
if not expr.as_real_imag()[1]:
return expr.evalf() > 0
else: return False

@staticmethod
def Basic(expr, assumptions):
if expr.is_number:

@staticmethod
def Mul(expr, assumptions):
if expr.is_number:
result = True
for arg in expr.args:
result = result ^ True
else: return
return result

@staticmethod
if expr.is_number:
for arg in expr.args:
if ask(Q.positive(arg), assumptions) is not True:
break
else:
# if all argument's are positive
return True

@staticmethod
def Pow(expr, assumptions):
if expr.is_number: return expr.evalf() > 0
return True
return True
return False

@staticmethod
def exp(expr, assumptions):