----- Original Message -----
From: "David Lehman" <dlehman(a)redhat.com>
To: anaconda-patches(a)lists.fedorahosted.org
Sent: Tuesday, November 18, 2014 9:56:07 AM
Subject: Re: [PATCH 4/5] New method to round a Size to a whole number of a specified
unit.
On 11/17/2014 05:41 PM, Anne Mulhern wrote:
>
>
>
>
> ----- Original Message -----
>> From: "David Lehman" <dlehman(a)redhat.com>
>> To: anaconda-patches(a)lists.fedorahosted.org
>> Sent: Monday, November 17, 2014 2:36:07 PM
>> Subject: [PATCH 4/5] New method to round a Size to a whole number of a
>> specified unit.
>>
>> ---
>> blivet/size.py | 17 ++++++++++++++++-
>> tests/size_test.py | 40 ++++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 56 insertions(+), 1 deletion(-)
>>
>> diff --git a/blivet/size.py b/blivet/size.py
>> index b5ef808..6d24fdf 100644
>> --- a/blivet/size.py
>> +++ b/blivet/size.py
>> @@ -26,13 +26,14 @@ from collections import namedtuple
>>
>> from decimal import Decimal
>> from decimal import InvalidOperation
>> -from decimal import ROUND_DOWN
>> +from decimal import ROUND_DOWN, ROUND_UP, ROUND_HALF_UP
>> import six
>>
>> from .errors import SizePlacesError
>> from .i18n import _, N_
>> from .util import stringize, unicodeize
>>
>> +ROUND_DEFAULT = ROUND_HALF_UP
>
> It would be nice for me if there was a comment here justifying preferring
> ROUND_HALF_UP to ROUND_HALF_EVEN
> (which is what we get from the default context).
>
> Is there really any benefit to not making the default just consistently
> ROUND_UP if it is not ROUND_HALF_EVEN?
My understanding is that half-even is mostly beneficial in terms of
being more consistent with negative numbers. Since we're talking about
sizes, we do not care about negative numbers.
To me, half-up is the expected default behavior for rounding. Maybe
others disagree.
I think that the purpose of ROUND_HALF_EVEN is to have a very cheap approximation
to "round in a random direction if right in the middle". This approximation
mostly
works if the relative frequencies of odd and even numbers is mostly random. The idea
is that it allows to avoid a persistent upward (or downward) skew in results
(which can make computationally intensive calculations erroneous).
I think that that problem is more or less irrelevant in the blivet context.
I was just wondering if there was some rationale for overriding the default having
to do with how Sizes are actually used in blivet.
<-- SNIP -->
_______________________________________________
anaconda-patches mailing list
anaconda-patches(a)lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
- mulhern