From 810e744ba5cdd7a0479041e1fccff2d75a9703de Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Thu, 14 Apr 2022 16:06:27 -0400 Subject: [PATCH] clean up --- tabulate.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tabulate.py b/tabulate.py index 9e91f24..f5cd51f 100644 --- a/tabulate.py +++ b/tabulate.py @@ -5,7 +5,7 @@ from __future__ import print_function from __future__ import unicode_literals from collections import namedtuple -from decimal import Decimal, getcontext, setcontext, Context +from decimal import Decimal import sys import re import math @@ -993,18 +993,15 @@ def _format(val, valtype, floatfmt, missingval="", has_invisible=True): val, (_text_type, _binary_type) ) if is_a_colored_number: - print("HIIIIII", val) raw_val = _strip_invisible(val) - formatted_val = format(Decimal(str(raw_val)), floatfmt) + formatted_val = format(float(val), floatfmt) return val.replace(raw_val, formatted_val) else: - context = Context(clamp=1, prec=6) - setcontext(context) try: if "f" in floatfmt: if int(Decimal(val)) == Decimal(val): - val = int(Decimal(val, context=context)) - val = Decimal(str(val), context=context) + val = int(Decimal(val)) + val = Decimal(str(val)) else: val = float(val) except (OverflowError, ValueError):