On Mar 28, 2010, at 2:50 PM, Vinzent Steinberg wrote:

> 2010/3/28 Øyvind Jensen <jensen.oyv...@gmail.com>
> All comparisons of for non-commutative symbols used to return False.  Now
> an Inequality or StrictInequality is returned instead.
> 
> Added a test.
> ---
>  sympy/core/basic.py            |   12 +++++-------
>  sympy/core/tests/test_basic.py |    8 ++++++++
>  2 files changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/sympy/core/basic.py b/sympy/core/basic.py
> index 8cfc08e..c238769 100644
> --- a/sympy/core/basic.py
> +++ b/sympy/core/basic.py
> @@ -652,33 +652,31 @@ def __ne__(self, other):
> 
>     @_sympifyit('other', False) # sympy >  other
>     def __lt__(self, other):
> -        #return sympify(other) > self
>         dif = self - other
> -        if not dif.is_negative is None:
> +        if dif.is_negative != dif.is_nonnegative:
>             return dif.is_negative
>         return StrictInequality(self, other)
> 
>     @_sympifyit('other', True)  # sympy >  other
>     def __gt__(self, other):
>         dif = self - other
> -        if not dif.is_negative is None:
> +        if dif.is_positive !=  dif.is_nonpositive:
>             return dif.is_positive
>         return StrictInequality(other, self)
> -        #return sympify(other) < self
> 
>     @_sympifyit('other', False) # sympy >  other
>     def __le__(self, other):
>         dif = self - other
> -        if not dif.is_nonpositive is None:
> +        if dif.is_nonpositive != dif.is_positive:
>             return dif.is_nonpositive
>         return Inequality(self, other)
> 
>     @_sympifyit('other', True)  # sympy >  other
>     def __ge__(self, other):
>         dif = self - other
> -        if not dif.is_nonnegative is None:
> +        if dif.is_nonnegative != dif.is_negative:
>             return dif.is_nonnegative
> -        return sympify(other) <= self
> +        return Inequality(other, self)
> 
> 
>     # ***************
> diff --git a/sympy/core/tests/test_basic.py b/sympy/core/tests/test_basic.py
> index da4533f..5df8b08 100644
> --- a/sympy/core/tests/test_basic.py
> +++ b/sympy/core/tests/test_basic.py
> @@ -155,6 +155,14 @@ def test_relational():
>     assert (-pi >= 3) == False
>     assert (x - 2 < x - 3) == False
> 
> +def test_relational_noncommutative():
> +    from sympy import Lt, Gt, Le, Ge
> +    a,b = symbols('a b', noncommutative=True)
> +    assert (a<b)  == Lt(a,b)
> +    assert (a<=b) == Le(a,b)
> +    assert (a>b)  == Gt(a,b)
> +    assert (a>=b) == Ge(a,b)
> +
>  def test_basic_nostr():
>     for obj in basic_objs:
>         for op in ['+','-','*','/','**']:
> --
> 1.6.5
> 
> The added tests pass without your patch, so I don't understand what you are 
> actually fixing.
> 
I think he meant to put commutative=False, not noncommutative=True.  It's weird 
that Symbol will let you create nonexistent assumptions on it:

In [68]: Symbol('r', something=True)
Out[68]: r

Aaron Meurer

-- 
You received this message because you are subscribed to the Google Groups 
"sympy-patches" group.
To post to this group, send email to sympy-patc...@googlegroups.com.
To unsubscribe from this group, send email to 
sympy-patches+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy-patches?hl=en.

Reply via email to