Elias Zamaria <mikez...@gmail.com> added the comment:

Mark, you have some good ideas. A fraction modulo a float is a float, and an 
integer modulo infinity produces itself as a float, so it seems reasonable that 
a fraction modulo infinity should be itself converted to a float.

I tried assigning __mod__ and __rmod__ using _operator_fallbacks, like most of 
the binary operators, and calculations involving infinity behaved as I 
expected, but one test failed (1.0 % Fraction(1, 10) was no longer 0 because of 
rounding error).

But then I tried assigning only __mod__ using _operator_fallbacks, and leaving 
__rmod__ alone, and all the tests passed (including some ones I added to make 
sure that modulo calculations involving infinity behave like both of us think 
they should).

As for the floordiv operator, I'm not sure what to think. It would be a bit 
strange if mod with a float returns a float and floordiv with a float returns 
an int. It wouldn't be a big deal IMO but it may be easy to change. I tried a 
simple change to make floordiv with a float to return a float, and changed one 
test to make sure that it works, and all of the tests passed.

I can make a pull request if anyone wants.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32968>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to