(self)
| 2318 | geometric_mean([10, 20, 60], 70) # too many arguments |
| 2319 | |
| 2320 | def test_special_values(self): |
| 2321 | # Rules for special values are inherited from math.fsum() |
| 2322 | geometric_mean = statistics.geometric_mean |
| 2323 | NaN = float('Nan') |
| 2324 | Inf = float('Inf') |
| 2325 | self.assertTrue(math.isnan(geometric_mean([10, NaN])), 'nan') |
| 2326 | self.assertTrue(math.isnan(geometric_mean([NaN, Inf])), 'nan and infinity') |
| 2327 | self.assertTrue(math.isinf(geometric_mean([10, Inf])), 'infinity') |
| 2328 | with self.assertRaises(ValueError): |
| 2329 | geometric_mean([Inf, -Inf]) |
| 2330 | |
| 2331 | # Cases with zero |
| 2332 | self.assertEqual(geometric_mean([3, 0.0, 5]), 0.0) # Any zero gives a zero |
| 2333 | self.assertEqual(geometric_mean([3, -0.0, 5]), 0.0) # Negative zero allowed |
| 2334 | self.assertTrue(math.isnan(geometric_mean([0, NaN]))) # NaN beats zero |
| 2335 | self.assertTrue(math.isnan(geometric_mean([0, Inf]))) # Because 0.0 * Inf -> NaN |
| 2336 | |
| 2337 | def test_mixed_int_and_float(self): |
| 2338 | # Regression test for b.p.o. issue #28327 |
nothing calls this directly
no test coverage detected