Esempio n. 1
0
def _eval_is_ge(lhs, rhs):  # noqa: F811
    """
    Returns ``True`` if range of values attained by ``lhs`` AccumulationBounds
    object is less that the range of values attained by ``rhs``, where
    other may be any value of type AccumulationBounds object or extended
    real number value, ``False`` if ``rhs`` satisfies the same
    property, else an unevaluated :py:class:`~.Relational`.

    Examples
    ========

    >>> from sympy import AccumBounds, oo
    >>> AccumBounds(1, 3) >= AccumBounds(4, oo)
    False
    >>> AccumBounds(1, 4) >= AccumBounds(3, 4)
    AccumBounds(1, 4) >= AccumBounds(3, 4)
    >>> AccumBounds(1, oo) >= 1
    True
    """

    if not rhs.is_extended_real:
        raise TypeError("Invalid comparison of %s %s" % (type(rhs), rhs))
    elif rhs.is_comparable:
        if is_ge(lhs.min, rhs):
            return True
        if is_lt(lhs.max, rhs):
            return False
Esempio n. 2
0
def test_is_ge_le():
    # test assumptions
    assert is_ge(x, S(0), Q.nonnegative(x)) is True
    assert is_ge(x, S(0), Q.negative(x)) is False

    # test registration
    class PowTest(Expr):
        def __new__(cls, base, exp):
            return Basic.__new__(cls, _sympify(base), _sympify(exp))

    @dispatch(PowTest, PowTest)
    def _eval_is_ge(lhs, rhs):
        if type(lhs) == PowTest and type(rhs) == PowTest:
            return fuzzy_and([
                is_ge(lhs.args[0], rhs.args[0]),
                is_ge(lhs.args[1], rhs.args[1])
            ])

    assert is_ge(PowTest(3, 9), PowTest(3, 2))
    assert is_gt(PowTest(3, 9), PowTest(3, 2))
    assert is_le(PowTest(3, 2), PowTest(3, 9))
    assert is_lt(PowTest(3, 2), PowTest(3, 9))
Esempio n. 3
0
def test_is_ge_le():
    class PowTest(Expr):
        def __new__(cls, base, exp):
            return Basic.__new__(cls, _sympify(base), _sympify(exp))

    @dispatch(PowTest, PowTest)
    def _eval_is_ge(lhs, rhs):
        if type(lhs) == PowTest and type(rhs) == PowTest:
            return fuzzy_and([is_ge(lhs.args[0], rhs.args[0]), is_ge(lhs.args[1], rhs.args[1])])

    assert is_ge(PowTest(3, 9), PowTest(3,2))
    assert is_gt(PowTest(3, 9), PowTest(3,2))
    assert is_le(PowTest(3, 2), PowTest(3,9))
    assert is_lt(PowTest(3, 2), PowTest(3,9))
Esempio n. 4
0
 def _eval_is_ge(lhs, rhs):
     if type(lhs) == PowTest and type(rhs) == PowTest:
         return fuzzy_and([
             is_ge(lhs.args[0], rhs.args[0]),
             is_ge(lhs.args[1], rhs.args[1])
         ])
Esempio n. 5
0
def test_18778():
    raises(TypeError, lambda: is_le(Basic(), Basic()))
    raises(TypeError, lambda: is_gt(Basic(), Basic()))
    raises(TypeError, lambda: is_ge(Basic(), Basic()))
    raises(TypeError, lambda: is_lt(Basic(), Basic()))
Esempio n. 6
0
def _eval_is_ge(lhs, rhs):  # noqa:F811
    if is_ge(lhs.min, rhs.max):
        return True
    if is_lt(lhs.max, rhs.min):
        return False
Esempio n. 7
0
 def eval(self, args, assumptions=True):
     return is_ge(*args)
Esempio n. 8
0
 def eval(self, args, assumptions=True):
     if assumptions == True:
         # default assumptions for is_ge is None
         assumptions = None
     return is_ge(*args, assumptions)