diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2024-05-05 17:29:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-05 17:29:23 (GMT) |
commit | 5092ea238e28c7d099c662d416b2a96fdbea4790 (patch) | |
tree | 0266e5db030fd8f5544c5689949e1cb896ef88bb /Lib/statistics.py | |
parent | 9c13d9e37a194f574b8591da634bf98419786448 (diff) | |
download | cpython-5092ea238e28c7d099c662d416b2a96fdbea4790.zip cpython-5092ea238e28c7d099c662d416b2a96fdbea4790.tar.gz cpython-5092ea238e28c7d099c662d416b2a96fdbea4790.tar.bz2 |
Fix negative bandwidth test and add online code path test. (gh-118600)
Diffstat (limited to 'Lib/statistics.py')
-rw-r--r-- | Lib/statistics.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/statistics.py b/Lib/statistics.py index f3ce2d8..c2f4fe8 100644 --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -1791,9 +1791,8 @@ def kde_random(data, h, kernel='normal', *, seed=None): if h <= 0.0: raise StatisticsError(f'Bandwidth h must be positive, not {h=!r}') - try: - kernel_invcdf = _kernel_invcdfs[kernel] - except KeyError: + kernel_invcdf = _kernel_invcdfs.get(kernel) + if kernel_invcdf is None: raise StatisticsError(f'Unknown kernel name: {kernel!r}') prng = _random.Random(seed) |