MCPcopy Index your code
hub / github.com/python/cpython / test_big_and_small

Method test_big_and_small

Lib/test/test_statistics.py:2283–2296  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2281 self.assertAlmostEqual(actual_mean, expected_mean, places=5)
2282
2283 def test_big_and_small(self):
2284 geometric_mean = statistics.geometric_mean
2285
2286 # Avoid overflow to infinity
2287 large = 2.0 ** 1000
2288 big_gm = geometric_mean([54.0 * large, 24.0 * large, 36.0 * large])
2289 self.assertTrue(math.isclose(big_gm, 36.0 * large))
2290 self.assertFalse(math.isinf(big_gm))
2291
2292 # Avoid underflow to zero
2293 small = 2.0 ** -1000
2294 small_gm = geometric_mean([54.0 * small, 24.0 * small, 36.0 * small])
2295 self.assertTrue(math.isclose(small_gm, 36.0 * small))
2296 self.assertNotEqual(small_gm, 0.0)
2297
2298 def test_error_cases(self):
2299 geometric_mean = statistics.geometric_mean

Callers

nothing calls this directly

Calls 4

geometric_meanFunction · 0.85
assertTrueMethod · 0.80
assertFalseMethod · 0.80
assertNotEqualMethod · 0.80

Tested by

no test coverage detected