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

Method test_weights

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

Source from the content-addressed store, hash-verified

1917 fmean([Inf, -Inf])
1918
1919 def test_weights(self):
1920 fmean = statistics.fmean
1921 StatisticsError = statistics.StatisticsError
1922 self.assertEqual(
1923 fmean([10, 10, 10, 50], [0.25] * 4),
1924 fmean([10, 10, 10, 50]))
1925 self.assertEqual(
1926 fmean([10, 10, 20], [0.25, 0.25, 0.50]),
1927 fmean([10, 10, 20, 20]))
1928 self.assertEqual( # inputs are iterators
1929 fmean(iter([10, 10, 20]), iter([0.25, 0.25, 0.50])),
1930 fmean([10, 10, 20, 20]))
1931 with self.assertRaises(StatisticsError):
1932 fmean([10, 20, 30], [1, 2]) # unequal lengths
1933 with self.assertRaises(StatisticsError):
1934 fmean(iter([10, 20, 30]), iter([1, 2])) # unequal lengths
1935 with self.assertRaises(StatisticsError):
1936 fmean([10, 20], [-1, 1]) # sum of weights is zero
1937 with self.assertRaises(StatisticsError):
1938 fmean(iter([10, 20]), iter([-1, 1])) # sum of weights is zero
1939
1940
1941# === Tests for variances and standard deviations ===

Callers

nothing calls this directly

Calls 3

fmeanFunction · 0.85
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected