mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Clean-up and simplify median_grouped(). Vastly improve its docstring. (#92324)
This commit is contained in:
parent
b885b8f4be
commit
5212cbc261
2 changed files with 49 additions and 91 deletions
|
@ -1040,50 +1040,6 @@ class FailNegTest(unittest.TestCase):
|
|||
self.assertEqual(errmsg, msg)
|
||||
|
||||
|
||||
class FindLteqTest(unittest.TestCase):
|
||||
# Test _find_lteq private function.
|
||||
|
||||
def test_invalid_input_values(self):
|
||||
for a, x in [
|
||||
([], 1),
|
||||
([1, 2], 3),
|
||||
([1, 3], 2)
|
||||
]:
|
||||
with self.subTest(a=a, x=x):
|
||||
with self.assertRaises(ValueError):
|
||||
statistics._find_lteq(a, x)
|
||||
|
||||
def test_locate_successfully(self):
|
||||
for a, x, expected_i in [
|
||||
([1, 1, 1, 2, 3], 1, 0),
|
||||
([0, 1, 1, 1, 2, 3], 1, 1),
|
||||
([1, 2, 3, 3, 3], 3, 2)
|
||||
]:
|
||||
with self.subTest(a=a, x=x):
|
||||
self.assertEqual(expected_i, statistics._find_lteq(a, x))
|
||||
|
||||
|
||||
class FindRteqTest(unittest.TestCase):
|
||||
# Test _find_rteq private function.
|
||||
|
||||
def test_invalid_input_values(self):
|
||||
for a, l, x in [
|
||||
([1], 2, 1),
|
||||
([1, 3], 0, 2)
|
||||
]:
|
||||
with self.assertRaises(ValueError):
|
||||
statistics._find_rteq(a, l, x)
|
||||
|
||||
def test_locate_successfully(self):
|
||||
for a, l, x, expected_i in [
|
||||
([1, 1, 1, 2, 3], 0, 1, 2),
|
||||
([0, 1, 1, 1, 2, 3], 0, 1, 3),
|
||||
([1, 2, 3, 3, 3], 0, 3, 4)
|
||||
]:
|
||||
with self.subTest(a=a, l=l, x=x):
|
||||
self.assertEqual(expected_i, statistics._find_rteq(a, l, x))
|
||||
|
||||
|
||||
# === Tests for public functions ===
|
||||
|
||||
class UnivariateCommonMixin:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue