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

Method test_basics

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

Source from the content-addressed store, hash-verified

1873class TestFMean(unittest.TestCase):
1874
1875 def test_basics(self):
1876 fmean = statistics.fmean
1877 D = Decimal
1878 F = Fraction
1879 for data, expected_mean, kind in [
1880 ([3.5, 4.0, 5.25], 4.25, 'floats'),
1881 ([D('3.5'), D('4.0'), D('5.25')], 4.25, 'decimals'),
1882 ([F(7, 2), F(4, 1), F(21, 4)], 4.25, 'fractions'),
1883 ([True, False, True, True, False], 0.60, 'booleans'),
1884 ([3.5, 4, F(21, 4)], 4.25, 'mixed types'),
1885 ((3.5, 4.0, 5.25), 4.25, 'tuple'),
1886 (iter([3.5, 4.0, 5.25]), 4.25, 'iterator'),
1887 ]:
1888 actual_mean = fmean(data)
1889 self.assertIs(type(actual_mean), float, kind)
1890 self.assertEqual(actual_mean, expected_mean, kind)
1891
1892 def test_error_cases(self):
1893 fmean = statistics.fmean

Callers

nothing calls this directly

Calls 5

fmeanFunction · 0.85
DClass · 0.70
FClass · 0.70
assertIsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected