Skip to content

Commit 810e744

Browse files
committed
clean up
1 parent 07e9ef6 commit 810e744

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

tabulate.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from __future__ import print_function
66
from __future__ import unicode_literals
77
from collections import namedtuple
8-
from decimal import Decimal, getcontext, setcontext, Context
8+
from decimal import Decimal
99
import sys
1010
import re
1111
import math
@@ -993,18 +993,15 @@ def _format(val, valtype, floatfmt, missingval="", has_invisible=True):
993993
val, (_text_type, _binary_type)
994994
)
995995
if is_a_colored_number:
996-
print("HIIIIII", val)
997996
raw_val = _strip_invisible(val)
998-
formatted_val = format(Decimal(str(raw_val)), floatfmt)
997+
formatted_val = format(float(val), floatfmt)
999998
return val.replace(raw_val, formatted_val)
1000999
else:
1001-
context = Context(clamp=1, prec=6)
1002-
setcontext(context)
10031000
try:
10041001
if "f" in floatfmt:
10051002
if int(Decimal(val)) == Decimal(val):
1006-
val = int(Decimal(val, context=context))
1007-
val = Decimal(str(val), context=context)
1003+
val = int(Decimal(val))
1004+
val = Decimal(str(val))
10081005
else:
10091006
val = float(val)
10101007
except (OverflowError, ValueError):

0 commit comments

Comments
 (0)