summaryrefslogtreecommitdiffstats
path: root/Lib/statistics.py
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2023-10-01 04:35:54 (GMT)
committerGitHub <noreply@github.com>2023-10-01 04:35:54 (GMT)
commit62405c7867b03730f0d278ea845855692d262d44 (patch)
treea5e220ee8d106b2ea59ed23031401228c6cf25a0 /Lib/statistics.py
parenta46e96076898d126c9f276aef1934195aac34b4e (diff)
downloadcpython-62405c7867b03730f0d278ea845855692d262d44.zip
cpython-62405c7867b03730f0d278ea845855692d262d44.tar.gz
cpython-62405c7867b03730f0d278ea845855692d262d44.tar.bz2
gh-110150: Fix base case handling in quantiles() (gh-110151)
Diffstat (limited to 'Lib/statistics.py')
-rw-r--r--Lib/statistics.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/statistics.py b/Lib/statistics.py
index 96c8034..4da0688 100644
--- a/Lib/statistics.py
+++ b/Lib/statistics.py
@@ -844,7 +844,9 @@ def quantiles(data, *, n=4, method='exclusive'):
data = sorted(data)
ld = len(data)
if ld < 2:
- raise StatisticsError('must have at least two data points')
+ if ld == 1:
+ return data * (n - 1)
+ raise StatisticsError('must have at least one data point')
if method == 'inclusive':
m = ld - 1
result = []