Hashable bounded typevar for mode, multimode (#4084)

Fixes #4057
This commit is contained in:
Luciano Ramalho
2020-05-26 01:48:25 -03:00
committed by GitHub
parent 3b02ce2128
commit 2f82c44af0

View File

@@ -3,7 +3,7 @@
from decimal import Decimal
from fractions import Fraction
import sys
from typing import Any, Iterable, List, Optional, SupportsFloat, Type, TypeVar, Union, Protocol
from typing import Any, Iterable, List, Optional, SupportsFloat, Type, TypeVar, Union, Protocol, Hashable
_T = TypeVar("_T")
# Most functions in this module accept homogeneous collections of one of these types
@@ -14,6 +14,9 @@ class _Sortable(Protocol):
def __lt__(self, other) -> bool: ...
_SortableT = TypeVar("_SortableT", bound=_Sortable)
# Used in mode, multimode
_HashableT = TypeVar("_HashableT", bound=Hashable)
class StatisticsError(ValueError): ...
if sys.version_info >= (3, 8):
@@ -26,9 +29,9 @@ def median(data: Iterable[_Number]) -> _Number: ...
def median_low(data: Iterable[_SortableT]) -> _SortableT: ...
def median_high(data: Iterable[_SortableT]) -> _SortableT: ...
def median_grouped(data: Iterable[_Number], interval: _Number = ...) -> _Number: ...
def mode(data: Iterable[_Number]) -> _Number: ...
def mode(data: Iterable[_HashableT]) -> _HashableT: ...
if sys.version_info >= (3, 8):
def multimode(data: Iterable[_T]) -> List[_T]: ...
def multimode(data: Iterable[_HashableT]) -> List[_HashableT]: ...
def pstdev(data: Iterable[_Number], mu: Optional[_Number] = ...) -> _Number: ...
def pvariance(data: Iterable[_Number], mu: Optional[_Number] = ...) -> _Number: ...
if sys.version_info >= (3, 8):