mirror of https://github.com/python/cpython
bpo-44960: add regression test for geometric_mean with mixed int/floa… (#27856)
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
This commit is contained in:
parent
60b93d9e49
commit
f5d7a8d29c
|
@ -2263,6 +2263,22 @@ class TestGeometricMean(unittest.TestCase):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
geometric_mean([Inf, -Inf])
|
geometric_mean([Inf, -Inf])
|
||||||
|
|
||||||
|
def test_mixed_int_and_float(self):
|
||||||
|
# Regression test for b.p.o. issue #28327
|
||||||
|
geometric_mean = statistics.geometric_mean
|
||||||
|
expected_mean = 3.80675409583932
|
||||||
|
values = [
|
||||||
|
[2, 3, 5, 7],
|
||||||
|
[2, 3, 5, 7.0],
|
||||||
|
[2, 3, 5.0, 7.0],
|
||||||
|
[2, 3.0, 5.0, 7.0],
|
||||||
|
[2.0, 3.0, 5.0, 7.0],
|
||||||
|
]
|
||||||
|
for v in values:
|
||||||
|
with self.subTest(v=v):
|
||||||
|
actual_mean = geometric_mean(v)
|
||||||
|
self.assertAlmostEqual(actual_mean, expected_mean, places=5)
|
||||||
|
|
||||||
|
|
||||||
class TestQuantiles(unittest.TestCase):
|
class TestQuantiles(unittest.TestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue