From f5d7a8d29c49ad47254fa098abb7a510e5e7b45e Mon Sep 17 00:00:00 2001 From: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Date: Fri, 20 Aug 2021 14:08:21 +0100 Subject: [PATCH] =?utf8?q?bpo-44960:=20add=20regression=20test=20for=20geo?= =?utf8?q?metric=5Fmean=20with=20mixed=20int/floa=E2=80=A6=20(#27856)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Co-authored-by: Mark Dickinson --- Lib/test/test_statistics.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py index a7cb02772696..dc066fa921d7 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): -- 2.47.3