Fix negative bandwidth test and add online code path test. (gh-118600)

This commit is contained in:
Raymond Hettinger 2024-05-05 12:29:23 -05:00 committed by GitHub
parent 9c13d9e37a
commit 5092ea238e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 9 deletions

View file

@ -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)