mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-140938: Raise ValueError for infinite inputs to stdev/pstdev (GH-141531)
Raise ValueError for infinite inputs to stdev/pstdev --- Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
1281be1caf
commit
f0a8bc737a
3 changed files with 24 additions and 5 deletions
|
|
@ -2005,7 +2005,6 @@ def test_iter_list_same(self):
|
|||
expected = self.func(data)
|
||||
self.assertEqual(self.func(iter(data)), expected)
|
||||
|
||||
|
||||
class TestPVariance(VarianceStdevMixin, NumericTestCase, UnivariateTypeMixin):
|
||||
# Tests for population variance.
|
||||
def setUp(self):
|
||||
|
|
@ -2113,6 +2112,14 @@ def test_center_not_at_mean(self):
|
|||
self.assertEqual(self.func(data), 2.5)
|
||||
self.assertEqual(self.func(data, mu=0.5), 6.5)
|
||||
|
||||
def test_gh_140938(self):
|
||||
# Inputs with inf/nan should raise a ValueError
|
||||
with self.assertRaises(ValueError):
|
||||
self.func([1.0, math.inf])
|
||||
with self.assertRaises(ValueError):
|
||||
self.func([1.0, math.nan])
|
||||
|
||||
|
||||
class TestSqrtHelpers(unittest.TestCase):
|
||||
|
||||
def test_integer_sqrt_of_frac_rto(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue