summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_statistics.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_statistics.py')
-rw-r--r--Lib/test/test_statistics.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py
index a9a427b..5b8ad87 100644
--- a/Lib/test/test_statistics.py
+++ b/Lib/test/test_statistics.py
@@ -2029,6 +2029,10 @@ class TestVariance(VarianceStdevMixin, NumericTestCase, UnivariateTypeMixin):
self.assertEqual(result, exact)
self.assertIsInstance(result, Decimal)
+ def test_center_not_at_mean(self):
+ data = (1.0, 2.0)
+ self.assertEqual(self.func(data), 0.5)
+ self.assertEqual(self.func(data, xbar=2.0), 1.0)
class TestPStdev(VarianceStdevMixin, NumericTestCase):
# Tests for population standard deviation.
@@ -2041,6 +2045,11 @@ class TestPStdev(VarianceStdevMixin, NumericTestCase):
expected = math.sqrt(statistics.pvariance(data))
self.assertEqual(self.func(data), expected)
+ def test_center_not_at_mean(self):
+ # See issue: 40855
+ data = (3, 6, 7, 10)
+ self.assertEqual(self.func(data), 2.5)
+ self.assertEqual(self.func(data, mu=0.5), 6.5)
class TestStdev(VarianceStdevMixin, NumericTestCase):
# Tests for sample standard deviation.
@@ -2058,6 +2067,9 @@ class TestStdev(VarianceStdevMixin, NumericTestCase):
expected = math.sqrt(statistics.variance(data))
self.assertEqual(self.func(data), expected)
+ def test_center_not_at_mean(self):
+ data = (1.0, 2.0)
+ self.assertEqual(self.func(data, xbar=2.0), 1.0)
class TestGeometricMean(unittest.TestCase):