summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_statistics.py
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2021-08-20 13:08:21 (GMT)
committerGitHub <noreply@github.com>2021-08-20 13:08:21 (GMT)
commitf5d7a8d29c49ad47254fa098abb7a510e5e7b45e (patch)
tree2f9c955abe6dc00d95dc770e00e258f5dede0b73 /Lib/test/test_statistics.py
parent60b93d9e4922eeae25052bc15909d1f4152babde (diff)
downloadcpython-f5d7a8d29c49ad47254fa098abb7a510e5e7b45e.zip
cpython-f5d7a8d29c49ad47254fa098abb7a510e5e7b45e.tar.gz
cpython-f5d7a8d29c49ad47254fa098abb7a510e5e7b45e.tar.bz2
bpo-44960: add regression test for geometric_mean with mixed int/floa… (#27856)
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
Diffstat (limited to 'Lib/test/test_statistics.py')
-rw-r--r--Lib/test/test_statistics.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py
index a7cb027..dc066fa 100644
--- a/Lib/test/test_statistics.py
+++ b/Lib/test/test_statistics.py
@@ -2263,6 +2263,22 @@ class TestGeometricMean(unittest.TestCase):
with self.assertRaises(ValueError):
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):