Repository: wireservice/agate

Issue:
Percentiles should be Decimals
For consistency

Discussion:

Patch:
diff --git a/agate/utils.py b/agate/utils.py
index e18e5f0..834e262 100644
--- a/agate/utils.py
+++ b/agate/utils.py
@@ -109,12 +109,12 @@ class Quantiles(Sequence):
             raise ValueError('Value is greater than maximum quantile value.')
 
         if value == self._quantiles[-1]:
-            return len(self._quantiles) - 1
+            return Decimal(len(self._quantiles) - 1)
 
         while value >= self._quantiles[i + 1]:
             i += 1
 
-        return i
+        return Decimal(i)
 
 
 def median(data_sorted):


Test patch:
diff --git a/tests/test_computations.py b/tests/test_computations.py
index bfc3a9b..c9c76b3 100644
--- a/tests/test_computations.py
+++ b/tests/test_computations.py
@@ -316,6 +316,8 @@ class TestTableComputation(unittest.TestCase):
         self.assertSequenceEqual(new_table.rows[500], (501, 50))
         self.assertSequenceEqual(new_table.rows[998], (999, 99))
         self.assertSequenceEqual(new_table.rows[999], (1000, 100))
+        self.assertIsInstance(new_table.columns['percentiles'][0], Decimal)
+        self.assertIsInstance(new_table.columns['percentiles'][-1], Decimal)
 
     def test_percentile_rank_invalid_types(self):
         with self.assertRaises(DataTypeError):