Skip to content

Commit 94b18cd

Browse files
committed
Fixed precision test error for read_csv
1 parent 91e6dda commit 94b18cd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pandas/io/tests/test_parsers.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -3187,7 +3187,8 @@ def test_compact_ints(self):
31873187

31883188
def test_precise_conversion(self):
31893189
# GH #8002
3190-
from decimal import Decimal
3190+
from decimal import Decimal, getcontext
3191+
getcontext().prec = 100
31913192
normal_errors = []
31923193
precise_errors = []
31933194
for num in np.linspace(1., 2., num=500): # test numbers between 1 and 2
@@ -3201,8 +3202,8 @@ def error(val):
32013202
normal_errors.append(error(normal_val))
32023203
precise_errors.append(error(precise_val))
32033204
self.assertEqual(roundtrip_val, float(text[2:])) # round-trip should match float()
3204-
self.assertTrue(sum(precise_errors) < sum(normal_errors))
3205-
self.assertTrue(max(precise_errors) < max(normal_errors))
3205+
self.assertTrue(sum(precise_errors) <= sum(normal_errors))
3206+
self.assertTrue(max(precise_errors) <= max(normal_errors))
32063207

32073208
def test_pass_dtype(self):
32083209
data = """\

0 commit comments

Comments
 (0)