From b28b545761b15f0d8dd572d73796052e24fa3cb2 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 18 Mar 2017 12:00:29 -0700 Subject: [PATCH 1/3] stub for statistics --- stdlib/3.4/statistics.pyi | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 stdlib/3.4/statistics.pyi diff --git a/stdlib/3.4/statistics.pyi b/stdlib/3.4/statistics.pyi new file mode 100644 index 000000000000..26d2e2b10bf0 --- /dev/null +++ b/stdlib/3.4/statistics.pyi @@ -0,0 +1,23 @@ +# Stubs for statistics + +from decimal import Decimal +from fractions import Fraction +from typing import Iterable, TypeVar + +# Most functions in this module accept homogeneous collections of one of these types +_Number = TypeVar(int, float, Decimal, Fraction) + +class StatisticsError(ValueError): ... + +def mean(data: Iterable[_Number]) -> _Number: ... +if sys.version_info >= (3, 6): + def harmonic_mean(data: Iterable[_Number]) -> _Number: ... +def median(data: Iterable[_Number]) -> _Number: ... +def median_low(data: Iterable[_Number]) -> _Number: ... +def median_high(data: Iterable[_Number]) -> _Number: ... +def median_grouped(data: Iterable[_Number]) -> _Number: ... +def mode(data: Iterable[_Number]) -> _Number: ... +def pstdev(data: Iterable[_Number], mu: Optional[_Number] = ...) -> _Number: ... +def pvariance(data: Iterable[_Number], mu: Optional[_Number] = ...) -> _Number: ... +def stdev(data: Iterable[_Number], xbar: Optional[_Number] = ...) -> _Number: ... +def variance(data: Iterable[_Number], xbar: Optional[_Number] = ...) -> _Number: ... From 12e1cd6a9574a77f09499b10d8fce63e80aa4817 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 18 Mar 2017 12:26:59 -0700 Subject: [PATCH 2/3] fix missing imports --- stdlib/3.4/statistics.pyi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stdlib/3.4/statistics.pyi b/stdlib/3.4/statistics.pyi index 26d2e2b10bf0..6743b6dc66aa 100644 --- a/stdlib/3.4/statistics.pyi +++ b/stdlib/3.4/statistics.pyi @@ -2,10 +2,11 @@ from decimal import Decimal from fractions import Fraction -from typing import Iterable, TypeVar +import sys +from typing import Iterable, Optional, TypeVar # Most functions in this module accept homogeneous collections of one of these types -_Number = TypeVar(int, float, Decimal, Fraction) +_Number = TypeVar('_Number', int, float, Decimal, Fraction) class StatisticsError(ValueError): ... From 2938c0cbaf145acbeb4408353995edc5f0df6f40 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 18 Mar 2017 12:37:38 -0700 Subject: [PATCH 3/3] drop int from the typevar --- stdlib/3.4/statistics.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3.4/statistics.pyi b/stdlib/3.4/statistics.pyi index 6743b6dc66aa..d9116e58730b 100644 --- a/stdlib/3.4/statistics.pyi +++ b/stdlib/3.4/statistics.pyi @@ -6,7 +6,7 @@ import sys from typing import Iterable, Optional, TypeVar # Most functions in this module accept homogeneous collections of one of these types -_Number = TypeVar('_Number', int, float, Decimal, Fraction) +_Number = TypeVar('_Number', float, Decimal, Fraction) class StatisticsError(ValueError): ...