summaryrefslogtreecommitdiffstats
path: root/Lib/statistics.py
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2021-12-01 01:25:57 (GMT)
committerGitHub <noreply@github.com>2021-12-01 01:25:57 (GMT)
commit0aa0bd056349f73de9577ccc38560c1d01864d51 (patch)
treeb12f036967e471c117f3fcb54fc6ae0a55ddc02c /Lib/statistics.py
parenta39f46afdead515e7ac3722464b5ee8d7b0b2c9b (diff)
downloadcpython-0aa0bd056349f73de9577ccc38560c1d01864d51.zip
cpython-0aa0bd056349f73de9577ccc38560c1d01864d51.tar.gz
cpython-0aa0bd056349f73de9577ccc38560c1d01864d51.tar.bz2
bpo-45876: Have stdev() also use decimal specific square root. (GH-29869)
Diffstat (limited to 'Lib/statistics.py')
-rw-r--r--Lib/statistics.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/statistics.py b/Lib/statistics.py
index 9f1efa2..ff19ce9 100644
--- a/Lib/statistics.py
+++ b/Lib/statistics.py
@@ -920,9 +920,8 @@ def stdev(data, xbar=None):
raise StatisticsError('stdev requires at least two data points')
T, ss = _ss(data, xbar)
mss = ss / (n - 1)
- if hasattr(T, 'sqrt'):
- var = _convert(mss, T)
- return var.sqrt()
+ if issubclass(T, Decimal):
+ return _decimal_sqrt_of_frac(mss.numerator, mss.denominator)
return _float_sqrt_of_frac(mss.numerator, mss.denominator)