From 8e1576fcd55ede3a0d139cc90ec7eae4a5276c5f Mon Sep 17 00:00:00 2001 From: manoj Date: Sun, 17 May 2026 17:36:58 +0530 Subject: [PATCH 1/2] Fix validation in kde() and kde_random() --- Lib/statistics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/statistics.py b/Lib/statistics.py index 01ca6c51dafcaf..ab062ee4b6d8c9 100644 --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -1037,7 +1037,7 @@ def kde(data, h, kernel='normal', *, cumulative=False): if not n: raise StatisticsError('Empty data sequence') - if not isinstance(data[0], (int, float)): + if not all(isinstance(x,(int,float)) for x in data): raise TypeError('Data sequence must contain ints or floats') if h <= 0.0: @@ -1114,7 +1114,7 @@ def kde_random(data, h, kernel='normal', *, seed=None): if not n: raise StatisticsError('Empty data sequence') - if not isinstance(data[0], (int, float)): + if not all(isinstance(x,(int,float)) for x in data): raise TypeError('Data sequence must contain ints or floats') if h <= 0.0: From bc5e569500846a37cec47a4b1932d6186b8b0325 Mon Sep 17 00:00:00 2001 From: manoj Date: Sun, 17 May 2026 17:40:07 +0530 Subject: [PATCH 2/2] Fix validation in kde() and kde_random() --- Lib/statistics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/statistics.py b/Lib/statistics.py index ab062ee4b6d8c9..a96c5854c1c43c 100644 --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -1037,7 +1037,7 @@ def kde(data, h, kernel='normal', *, cumulative=False): if not n: raise StatisticsError('Empty data sequence') - if not all(isinstance(x,(int,float)) for x in data): + if not all(isinstance(x, (int, float)) for x in data): raise TypeError('Data sequence must contain ints or floats') if h <= 0.0: @@ -1114,7 +1114,7 @@ def kde_random(data, h, kernel='normal', *, seed=None): if not n: raise StatisticsError('Empty data sequence') - if not all(isinstance(x,(int,float)) for x in data): + if not all(isinstance(x, (int, float)) for x in data): raise TypeError('Data sequence must contain ints or floats') if h <= 0.0: