Skip to content

Commit 434f86a

Browse files
committed
removed .rstrip('0').rstrip('.') when formatting float value in format_value()
1 parent b3bcef8 commit 434f86a

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

larray/util/misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def format_value(value, missing, precision=None):
8787
if value != value:
8888
return missing
8989
elif precision is not None:
90-
return '{:.{precision}f}'.format(value, precision=precision).rstrip('0').rstrip('.')
90+
return '{:.{precision}f}'.format(value, precision=precision)
9191
else:
9292
return str(value)
9393
elif isinstance(value, np.ndarray) and value.shape:

larray/util/options.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,27 @@ class set_printoptions(object):
6262
>>> with set_printoptions(display_width=60, edgeitems=2, precision=2):
6363
... print(arr)
6464
a\b b0 b1 ... b98 b99
65-
a0 0 0.33 ... 32.67 33
66-
a1 33.33 33.67 ... 66 66.33
65+
a0 0.00 0.33 ... 32.67 33.00
66+
a1 33.33 33.67 ... 66.00 66.33
6767
... ... ... ... ... ...
68-
a498 16600 16600.33 ... 16632.67 16633
69-
a499 16633.33 16633.67 ... 16666 16666.33
68+
a498 16600.00 16600.33 ... 16632.67 16633.00
69+
a499 16633.33 16633.67 ... 16666.00 16666.33
7070
7171
Or to set global options:
7272
7373
>>> set_printoptions(display_width=40, maxlines=10, precision=2) # doctest: +SKIP
7474
>>> print(arr) # doctest: +SKIP
7575
a\b b0 ... b99
76-
a0 0 ... 33
76+
a0 0.00 ... 33.00
7777
a1 33.33 ... 66.33
7878
a2 66.67 ... 99.67
79-
a3 100 ... 133
79+
a3 100.00 ... 133.00
8080
a4 133.33 ... 166.33
8181
... ... ... ...
82-
a495 16500 ... 16533
82+
a495 16500.00 ... 16533.00
8383
a496 16533.33 ... 16566.33
8484
a497 16566.67 ... 16599.67
85-
a498 16600 ... 16633
85+
a498 16600.00 ... 16633.00
8686
a499 16633.33 ... 16666.33
8787
"""
8888

0 commit comments

Comments
 (0)