2009/8/11 Fabian Pedregosa <fab...@fseoane.net> > > oo % number now returns NaN instead of rasing an exception > --- > sympy/core/numbers.py | 3 +++ > sympy/core/tests/test_numbers.py | 1 + > 2 files changed, 4 insertions(+), 0 deletions(-) > > diff --git a/sympy/core/numbers.py b/sympy/core/numbers.py > index 11a2b72..59e86e5 100644 > --- a/sympy/core/numbers.py > +++ b/sympy/core/numbers.py > @@ -1190,6 +1190,9 @@ def __le__(a, b): > return True > return False > > + def __mod__(self, other): > + return S.NaN > + > > class NegativeInfinity(Rational): > __metaclass__ = SingletonMeta > diff --git a/sympy/core/tests/test_numbers.py > b/sympy/core/tests/test_numbers.py > index 876d782..3e9cdfc 100644 > --- a/sympy/core/tests/test_numbers.py > +++ b/sympy/core/tests/test_numbers.py > @@ -132,6 +132,7 @@ def test_Infinity(): > assert 1/oo == 0 > assert 1/(-oo) == 0 > assert 8/oo == 0 > + assert oo % 2 == nan > > def test_Infinity_2(): > x = Symbol('x') > -- > 1.6.4
>>> oo % 2 nan >>> 2 % oo Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for %: 'int' and 'Infinity' I think just adding __rmod__ = __mod__ fixes this. Vinzent --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-patches" group. To post to this group, send email to sympy-patches@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 -~----------~----~----~----~------~----~------~--~---