[blivet:master 2/2] Correct bug where fractional quantities were shown as exact.
Vratislav Podzimek
vpodzime at redhat.com
Fri Sep 5 07:11:32 UTC 2014
On Thu, 2014-09-04 at 10:34 -0400, mulhern wrote:
> To follow the basic engineering principle of not showing more
> precision than actually exists.
>
> Add a few more tests.
>
> Signed-off-by: mulhern <amulhern at redhat.com>
> ---
> blivet/size.py | 21 +++++++++++----------
> tests/size_test.py | 14 +++++++++++---
> 2 files changed, 22 insertions(+), 13 deletions(-)
>
> diff --git a/blivet/size.py b/blivet/size.py
> index b9f0089..9e930b1 100644
> --- a/blivet/size.py
> +++ b/blivet/size.py
> @@ -312,20 +312,21 @@ class Size(Decimal):
> return "%s %s" % (in_bytes, _("B"))
>
> retval = newcheck
> - if places is not None:
> - retval = round(newcheck, places)
> -
> - if max_places is not None:
> - if places is not None:
> - limit = min((places, max_places))
> - else:
> - limit = max_places
> - retval = round(newcheck, limit)
> -
> if retval == int(retval):
> # integer value, no point in showing ".0" at the end
> retval = int(retval)
>
> + else:
> + if places is not None:
> + retval = round(newcheck, places)
> +
> + if max_places is not None:
> + if places is not None:
> + limit = min((places, max_places))
> + else:
> + limit = max_places
> + retval = round(newcheck, limit)
I'm sorry, but I don't understand this change. The only difference I see
it makes is that if the rounded value due to a limitted number of places
results into an integer value, it is shown as a float instead of
integer. Cannot see a bug and fix here, can you please elaborate on it a
little bit more?
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list