summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Sheppard <kevin.k.sheppard@gmail.com>2021-02-19 15:17:19 +0000
committerKevin Sheppard <kevin.k.sheppard@gmail.com>2021-02-24 10:40:30 +0000
commit7f2db304655f80aa40c5f8481959561da15d160d (patch)
treeb9389437f9cf821d57c28d604913aeb164853725
parentd7bc29c1382cc31f3bc177f9ff6672d3f73e3076 (diff)
downloadnumpy-7f2db304655f80aa40c5f8481959561da15d160d.tar.gz
BUG: Corect typing statements in mtrand
Bring over changes from Generator to RandomState where appropriate Remove attributes not in RandomState
-rw-r--r--numpy/random/_generator.pyi8
-rw-r--r--numpy/random/mtrand.pyi83
2 files changed, 64 insertions, 27 deletions
diff --git a/numpy/random/_generator.pyi b/numpy/random/_generator.pyi
index a744dec67..51a231049 100644
--- a/numpy/random/_generator.pyi
+++ b/numpy/random/_generator.pyi
@@ -114,10 +114,6 @@ class Generator:
@overload
def permutation(self, x: ArrayLike, axis: int = ...) -> ndarray[Any, Any]: ...
@overload
- def standard_cauchy(self, size: None = ...) -> float: ... # type: ignore[misc]
- @overload
- def standard_cauchy(self, size: _ShapeLike = ...) -> ndarray[Any, dtype[float64]]: ...
- @overload
def standard_exponential( # type: ignore[misc]
self,
size: None = ...,
@@ -523,6 +519,10 @@ class Generator:
self, a: _ArrayLikeFloat_co, size: Optional[_ShapeLike] = ...
) -> ndarray[Any, dtype[float64]]: ...
@overload
+ def standard_cauchy(self, size: None = ...) -> float: ... # type: ignore[misc]
+ @overload
+ def standard_cauchy(self, size: _ShapeLike = ...) -> ndarray[Any, dtype[float64]]: ...
+ @overload
def laplace(self, loc: float = ..., scale: float = ..., size: None = ...) -> float: ... # type: ignore[misc]
@overload
def laplace(
diff --git a/numpy/random/mtrand.pyi b/numpy/random/mtrand.pyi
index f05635390..91c8d84a4 100644
--- a/numpy/random/mtrand.pyi
+++ b/numpy/random/mtrand.pyi
@@ -113,6 +113,11 @@ class RandomState:
def tomaxint(self, size: None = ...) -> int: ... # type: ignore[misc]
@overload
def tomaxint(self, size: _ShapeLike = ...) -> ndarray[Any, dtype[int_]]: ...
+ def randint( # type: ignore[misc]
+ self,
+ low: int,
+ high: Optional[int] = ...,
+ ) -> int: ...
@overload
def randint( # type: ignore[misc]
self,
@@ -120,6 +125,7 @@ class RandomState:
high: Optional[int] = ...,
size: None = ...,
dtype: _DTypeLikeBool = ...,
+ endpoint: bool = ...,
) -> bool: ...
@overload
def randint( # type: ignore[misc]
@@ -127,36 +133,31 @@ class RandomState:
low: int,
high: Optional[int] = ...,
size: None = ...,
- dtype: Union[_DTypeLikeInt, _DTypeLikeUInt] = ...,
- ) -> int: ...
+ dtype: _DTypeLikeBool = ...,
+ ) -> bool: ...
@overload
def randint( # type: ignore[misc]
self,
- low: _ArrayLikeInt_co,
- high: Optional[_ArrayLikeInt_co] = ...,
- size: Optional[_ShapeLike] = ...,
- dtype: Union[
- dtype[bool_], Type[bool], Type[bool_], _BoolCodes, _SupportsDType[dtype[bool_]]
- ] = ...,
- ) -> ndarray[Any, dtype[bool_]]: ...
+ low: int,
+ high: Optional[int] = ...,
+ size: None = ...,
+ dtype: Union[_DTypeLikeInt, _DTypeLikeUInt] = ...,
+ ) -> int: ...
@overload
def randint( # type: ignore[misc]
self,
low: _ArrayLikeInt_co,
high: Optional[_ArrayLikeInt_co] = ...,
size: Optional[_ShapeLike] = ...,
- dtype: Union[
- dtype[int_], Type[int], Type[int_], _IntCodes, _SupportsDType[dtype[int_]]
- ] = ...,
- ) -> ndarray[Any, dtype[int_]]: ...
+ ) -> ndarray[Any, dtype[int64]]: ...
@overload
def randint( # type: ignore[misc]
self,
low: _ArrayLikeInt_co,
high: Optional[_ArrayLikeInt_co] = ...,
size: Optional[_ShapeLike] = ...,
- dtype: Union[dtype[uint], Type[uint], _UIntCodes, _SupportsDType[dtype[uint]]] = ...,
- ) -> ndarray[Any, dtype[uint]]: ...
+ dtype: _DTypeLikeBool = ...,
+ ) -> ndarray[Any, dtype[bool_]]: ...
@overload
def randint( # type: ignore[misc]
self,
@@ -229,15 +230,58 @@ class RandomState:
dtype[uint64], Type[uint64], _UInt64Codes, _SupportsDType[dtype[uint64]]
] = ...,
) -> ndarray[Any, dtype[uint64]]: ...
+ @overload
+ def randint( # type: ignore[misc]
+ self,
+ low: _ArrayLikeInt_co,
+ high: Optional[_ArrayLikeInt_co] = ...,
+ size: Optional[_ShapeLike] = ...,
+ dtype: Union[
+ dtype[int_], Type[int], Type[int_], _IntCodes, _SupportsDType[dtype[int_]]
+ ] = ...,
+ ) -> ndarray[Any, dtype[int_]]: ...
+ @overload
+ def randint( # type: ignore[misc]
+ self,
+ low: _ArrayLikeInt_co,
+ high: Optional[_ArrayLikeInt_co] = ...,
+ size: Optional[_ShapeLike] = ...,
+ dtype: Union[dtype[uint], Type[uint], _UIntCodes, _SupportsDType[dtype[uint]]] = ...,
+ ) -> ndarray[Any, dtype[uint]]: ...
def bytes(self, length: int) -> bytes: ...
+ @overload
+ def choice(
+ self,
+ a: int,
+ size: None = ...,
+ replace: bool = ...,
+ p: Optional[_ArrayLikeFloat_co] = ...,
+ ) -> int: ...
+ @overload
+ def choice(
+ self,
+ a: int,
+ size: _ShapeLike = ...,
+ replace: bool = ...,
+ p: Optional[_ArrayLikeFloat_co] = ...,
+ ) -> ndarray[Any, dtype[int64]]: ...
+ @overload
def choice(
self,
a: ArrayLike,
- size: Optional[_ShapeLike] = ...,
+ size: None = ...,
replace: bool = ...,
p: Optional[_ArrayLikeFloat_co] = ...,
) -> Any: ...
@overload
+ def choice(
+ self,
+ a: ArrayLike,
+ size: _ShapeLike = ...,
+ replace: bool = ...,
+ p: Optional[_ArrayLikeFloat_co] = ...,
+ ) -> ndarray[Any, Any]: ...
+ @overload
def uniform(self, low: float = ..., high: float = ..., size: None = ...) -> float: ... # type: ignore[misc]
@overload
def uniform(
@@ -480,13 +524,6 @@ class RandomState:
def multinomial(
self, n: _ArrayLikeInt_co, pvals: _ArrayLikeFloat_co, size: Optional[_ShapeLike] = ...
) -> ndarray[Any, dtype[int_]]: ...
- def multivariate_hypergeometric(
- self,
- colors: _ArrayLikeInt_co,
- nsample: int,
- size: Optional[_ShapeLike] = ...,
- method: Literal["marginals", "count"] = ...,
- ) -> ndarray[Any, dtype[int_]]: ...
def dirichlet(
self, alpha: _ArrayLikeFloat_co, size: Optional[_ShapeLike] = ...
) -> ndarray[Any, dtype[float64]]: ...