Author elias
Recipients elias, mark.dickinson, rhettinger
Date 2018-03-01.05:17:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1519881470.89.0.467229070634.issue32968@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-03-01 05:17:50eliassetrecipients: + elias, rhettinger, mark.dickinson
2018-03-01 05:17:50eliassetmessageid: <1519881470.89.0.467229070634.issue32968@psf.upfronthosting.co.za>
2018-03-01 05:17:50eliaslinkissue32968 messages
2018-03-01 05:17:50eliascreate