summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorKevin Sheppard <kevin.k.sheppard@gmail.com>2021-02-23 17:26:37 +0000
committerKevin Sheppard <kevin.k.sheppard@gmail.com>2021-02-24 10:40:30 +0000
commitdc8481b0d6c87c564ad4e927abf8703f73eab696 (patch)
treedcb39ff24f8455f7e88e285f38cc401fee2acb8d /numpy
parentc282c31af54f7b67286ef3767966bede5c51b494 (diff)
downloadnumpy-dc8481b0d6c87c564ad4e927abf8703f73eab696.tar.gz
CLN: Clean up random typing
Clean unnecessary definitions Fix small typing errors
Diffstat (limited to 'numpy')
-rw-r--r--numpy/random/_generator.pyi15
-rw-r--r--numpy/random/mtrand.pyi14
2 files changed, 7 insertions, 22 deletions
diff --git a/numpy/random/_generator.pyi b/numpy/random/_generator.pyi
index 6b1a6f4af..14dc55131 100644
--- a/numpy/random/_generator.pyi
+++ b/numpy/random/_generator.pyi
@@ -1,5 +1,5 @@
import sys
-from typing import Any, Callable, Dict, Optional, Tuple, Type, Union, overload
+from typing import Any, Callable, Dict, Optional, Tuple, Type, Union, overload, TypeVar
from numpy import (
bool_,
@@ -49,6 +49,8 @@ if sys.version_info >= (3, 8):
else:
from typing_extensions import Literal
+_ArrayType = TypeVar("_ArrayType", bound=ndarray[Any, Any])
+
_DTypeLikeFloat32 = Union[
dtype[float32],
_SupportsDType[dtype[float32]],
@@ -72,7 +74,7 @@ class Generator:
def __str__(self) -> str: ...
def __getstate__(self) -> Dict[str, Any]: ...
def __setstate__(self, state: Dict[str, Any]) -> None: ...
- def __reduce__(self) -> Tuple[Callable[[str], BitGenerator], Tuple[str], Dict[str, Any]]: ...
+ def __reduce__(self) -> Tuple[Callable[[str], Generator], Tuple[str], Dict[str, Any]]: ...
@property
def bit_generator(self) -> BitGenerator: ...
def bytes(self, length: int) -> bytes: ...
@@ -222,15 +224,6 @@ class Generator:
low: int,
high: Optional[int] = ...,
size: None = ...,
- dtype: _DTypeLikeBool = ...,
- endpoint: bool = ...,
- ) -> bool: ...
- @overload
- def integers( # type: ignore[misc]
- self,
- low: int,
- high: Optional[int] = ...,
- size: None = ...,
dtype: Union[_DTypeLikeInt, _DTypeLikeUInt] = ...,
endpoint: bool = ...,
) -> int: ...
diff --git a/numpy/random/mtrand.pyi b/numpy/random/mtrand.pyi
index 814c294ac..fdf58c7e1 100644
--- a/numpy/random/mtrand.pyi
+++ b/numpy/random/mtrand.pyi
@@ -73,7 +73,7 @@ class RandomState:
def __str__(self) -> str: ...
def __getstate__(self) -> Dict[str, Any]: ...
def __setstate__(self, state: Dict[str, Any]) -> None: ...
- def __reduce__(self) -> Tuple[Callable[[str], BitGenerator], Tuple[str], Dict[str, Any]]: ...
+ def __reduce__(self) -> Tuple[Callable[[str], RandomState], Tuple[str], Dict[str, Any]]: ...
def seed(self, seed: Optional[_ArrayLikeFloat_co] = ...) -> None: ...
@overload
def get_state(self, legacy: Literal[False] = ...) -> Dict[str, Any]: ...
@@ -133,14 +133,6 @@ class RandomState:
low: int,
high: Optional[int] = ...,
size: None = ...,
- dtype: _DTypeLikeBool = ...,
- ) -> bool: ...
- @overload
- def randint( # type: ignore[misc]
- self,
- low: int,
- high: Optional[int] = ...,
- size: None = ...,
dtype: Union[_DTypeLikeInt, _DTypeLikeUInt] = ...,
) -> int: ...
@overload
@@ -291,11 +283,11 @@ class RandomState:
size: Optional[_ShapeLike] = ...,
) -> ndarray[Any, dtype[float64]]: ...
@overload
- def rand(self, *args: None) -> float: ...
+ def rand(self) -> float: ...
@overload
def rand(self, *args: int) -> ndarray[Any, dtype[float64]]: ...
@overload
- def randn(self, *args: None) -> float: ...
+ def randn(self) -> float: ...
@overload
def randn(self, *args: int) -> ndarray[Any, dtype[float64]]: ...
@overload