Fix inconsistent return type for statistics median_grouped() gh-92531 (#92533)

This commit is contained in:
Raymond Hettinger 2022-05-09 02:08:41 -05:00 committed by GitHub
parent 5bc2390229
commit e01eeb7b4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 14 deletions

View file

@ -1742,6 +1742,12 @@ class TestMedianGrouped(TestMedian):
data = [x]*count
self.assertEqual(self.func(data), float(x))
def test_single_value(self):
# Override method from AverageMixin.
# Average of a single value is the value as a float.
for x in (23, 42.5, 1.3e15, Fraction(15, 19), Decimal('0.28')):
self.assertEqual(self.func([x]), float(x))
def test_odd_fractions(self):
# Test median_grouped works with an odd number of Fractions.
F = Fraction