8000 bpo-44960: add regression test for geometric_mean with mixed int/floa… · python/cpython@f5d7a8d · GitHub
[go: up one dir, main page]

Skip to content

Commit f5d7a8d

Browse files
bpo-44960: add regression test for geometric_mean with mixed int/floa… (#27856)
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
1 parent 60b93d9 commit f5d7a8d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Lib/test/test_statistics.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,6 +2263,22 @@ def test_special_values(self):
22632263
with self.assertRaises(ValueError):
22642264
geometric_mean([Inf, -Inf])
22652265

2266+
def test_mixed_int_and_float(self):
2267+
# Regression test for b.p.o. issue #28327
2268+
geometric_mean = statistics.geometric_mean
2269+
expected_mean = 3.80675409583932
2270+
values = [
2271+
[2, 3, 5, 7],
2272+
[2, 3, 5, 7.0],
2273+
[2, 3, 5.0, 7.0],
2274+
[2, 3.0, 5.0, 7.0],
2275+
[2.0, 3.0, 5.0, 7.0],
2276+
]
2277+
for v in values:
2278+
with self.subTest(v=v):
2279+
actual_mean = geometric_mean(v)
2280+
self.assertAlmostEqual(actual_mean, expected_mean, places=5)
2281+
22662282

22672283
class TestQuantiles(unittest.TestCase):
22682284

0 commit comments

Comments
 (0)
0