From 65e1e0e4ba0909a45f410a24360e97568e2bb66a Mon Sep 17 00:00:00 2001 From: wrwrwr Date: Sat, 1 Oct 2016 21:44:38 +0200 Subject: BUG: Fix array printing with precision=0. Values rounding to zero were formatted with negative precision. --- numpy/core/arrayprint.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'numpy/core/arrayprint.py') diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index b05082e9d..cd618d72a 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -626,9 +626,12 @@ class FloatFormat(object): def _digits(x, precision, format): - s = format % x - z = s.rstrip('0') - return precision - len(s) + len(z) + if precision > 0: + s = format % x + z = s.rstrip('0') + return precision - len(s) + len(z) + else: + return 0 class IntegerFormat(object): -- cgit v1.2.1