From d00c35be19e721145a4e7253a7da768e6b649db7 Mon Sep 17 00:00:00 2001 From: Oliver Thomas <1835492+olliethomas@users.noreply.github.com> Date: Mon, 18 May 2020 20:51:05 +0100 Subject: [PATCH 1/3] found some wip changes --- numpy-stubs/__init__.pyi | 4 +++- numpy-stubs/random.pyi | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/numpy-stubs/__init__.pyi b/numpy-stubs/__init__.pyi index 4e2fe01..985c29e 100644 --- a/numpy-stubs/__init__.pyi +++ b/numpy-stubs/__init__.pyi @@ -278,6 +278,7 @@ class ndarray(Generic[_DType]): self, key: Union[ None, + range, slice, str, ndarray[_Int], @@ -593,6 +594,7 @@ def asarray(a: ndarray, dtype: Type[str]) -> ndarray[str_]: ... def atleast_2d(ary: _Coercable) -> ndarray: ... @overload def atleast_2d(ar: _Coercable, *ary: _Coercable) -> List[ndarray]: ... +def bincount(x : _ArrayLike[_DType], weights: _ArrayLike = ..., minlength: int = ... ) -> ndarray[_DType]: ... @overload def ceil(a: _FloatObj) -> _FloatObj: ... @overload @@ -640,7 +642,7 @@ def isin(element: Sequence[_DType], test_element: _DType) -> ndarray[_DType]: .. @overload def isnan(x: float64) -> bool: ... @overload -def isnan(x: ndarray[_DType]) -> ndarray[bool_]: ... +def isnan(x: _ArrayLike[_DType]) -> ndarray[bool_]: ... @overload def ix_(x: ndarray[_DType]) -> ndarray[_DType]: ... @overload diff --git a/numpy-stubs/random.pyi b/numpy-stubs/random.pyi index 8646838..2f7b3bb 100644 --- a/numpy-stubs/random.pyi +++ b/numpy-stubs/random.pyi @@ -1,6 +1,6 @@ from typing import Iterable, List, Optional, Sequence, Tuple, TypeVar, Union, overload -from . import _DType, _Float, _FloatObj, _Int, _IntObj, _ShapeType, float64, int64, ndarray +from . import _DType, _Float, _FloatObj, _Int, _IntObj, _ShapeType, float64, int64, ndarray, _ArrayLike _T = TypeVar("_T") @overload @@ -43,6 +43,7 @@ def exponential(scale: _FloatObj, size: Sequence[_IntObj]) -> ndarray[float64]: def exponential(scale: Sequence[_FloatObj], size: Sequence[_IntObj]) -> ndarray[float64]: ... def geometric(p: float, size: _IntObj) -> ndarray[float64]: ... def get_state() -> Tuple[str, ndarray[_Int], _IntObj, _IntObj, _FloatObj]: ... +def multinomial(n : int, pvals : _ArrayLike[float] = ..., size: Union[int, Tuple[int, ...]] = ...) -> ndarray[_Int]: ... def normal(loc: float, scale: float, size: Union[int, Tuple[int, ...]]) -> ndarray[float64]: ... @overload def permutation(size: int) -> ndarray[int64]: ... From b2bcc785cdc5dea909622cec951ce9642cd006f4 Mon Sep 17 00:00:00 2001 From: Oliver Thomas <1835492+olliethomas@users.noreply.github.com> Date: Tue, 19 May 2020 17:46:05 +0100 Subject: [PATCH 2/3] n oidea what this is, it was just on my machine --- numpy-stubs/__init__.pyi | 4 +++- numpy-stubs/random.pyi | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/numpy-stubs/__init__.pyi b/numpy-stubs/__init__.pyi index f00e4ec..eeb5198 100644 --- a/numpy-stubs/__init__.pyi +++ b/numpy-stubs/__init__.pyi @@ -596,7 +596,9 @@ def asarray(a: ndarray, dtype: Type[str]) -> ndarray[str_]: ... def atleast_2d(ary: _Coercable) -> ndarray: ... @overload def atleast_2d(ar: _Coercable, *ary: _Coercable) -> List[ndarray]: ... -def bincount(x : _ArrayLike[_DType], weights: _ArrayLike = ..., minlength: int = ... ) -> ndarray[_DType]: ... +def bincount( + x: _ArrayLike[_DType], weights: _ArrayLike = ..., minlength: int = ... +) -> ndarray[_DType]: ... @overload def ceil(a: _FloatObj) -> _FloatObj: ... @overload diff --git a/numpy-stubs/random.pyi b/numpy-stubs/random.pyi index 2f7b3bb..bf86ab4 100644 --- a/numpy-stubs/random.pyi +++ b/numpy-stubs/random.pyi @@ -1,6 +1,17 @@ from typing import Iterable, List, Optional, Sequence, Tuple, TypeVar, Union, overload -from . import _DType, _Float, _FloatObj, _Int, _IntObj, _ShapeType, float64, int64, ndarray, _ArrayLike +from . import ( + _DType, + _Float, + _FloatObj, + _Int, + _IntObj, + _ShapeType, + float64, + int64, + ndarray, + _ArrayLike, +) _T = TypeVar("_T") @overload @@ -43,7 +54,9 @@ def exponential(scale: _FloatObj, size: Sequence[_IntObj]) -> ndarray[float64]: def exponential(scale: Sequence[_FloatObj], size: Sequence[_IntObj]) -> ndarray[float64]: ... def geometric(p: float, size: _IntObj) -> ndarray[float64]: ... def get_state() -> Tuple[str, ndarray[_Int], _IntObj, _IntObj, _FloatObj]: ... -def multinomial(n : int, pvals : _ArrayLike[float] = ..., size: Union[int, Tuple[int, ...]] = ...) -> ndarray[_Int]: ... +def multinomial( + n: int, pvals: _ArrayLike[float] = ..., size: Union[int, Tuple[int, ...]] = ... +) -> ndarray[_Int]: ... def normal(loc: float, scale: float, size: Union[int, Tuple[int, ...]]) -> ndarray[float64]: ... @overload def permutation(size: int) -> ndarray[int64]: ... From d02d6c1b2d558d567a90d51154b7938cc9dedc7b Mon Sep 17 00:00:00 2001 From: Oliver Thomas <1835492+olliethomas@users.noreply.github.com> Date: Fri, 26 Jun 2020 10:10:16 +0100 Subject: [PATCH 3/3] followed tk`s suggestions --- numpy-stubs/__init__.pyi | 1 - numpy-stubs/random.pyi | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/numpy-stubs/__init__.pyi b/numpy-stubs/__init__.pyi index eeb5198..f4b2997 100644 --- a/numpy-stubs/__init__.pyi +++ b/numpy-stubs/__init__.pyi @@ -280,7 +280,6 @@ class ndarray(Generic[_DType]): self, key: Union[ None, - range, slice, str, ndarray[_Int], diff --git a/numpy-stubs/random.pyi b/numpy-stubs/random.pyi index bf86ab4..9469659 100644 --- a/numpy-stubs/random.pyi +++ b/numpy-stubs/random.pyi @@ -55,7 +55,7 @@ def exponential(scale: Sequence[_FloatObj], size: Sequence[_IntObj]) -> ndarray[ def geometric(p: float, size: _IntObj) -> ndarray[float64]: ... def get_state() -> Tuple[str, ndarray[_Int], _IntObj, _IntObj, _FloatObj]: ... def multinomial( - n: int, pvals: _ArrayLike[float] = ..., size: Union[int, Tuple[int, ...]] = ... + n: int, pvals: _ArrayLike[_Float] = ..., size: Union[int, Tuple[int, ...]] = ... ) -> ndarray[_Int]: ... def normal(loc: float, scale: float, size: Union[int, Tuple[int, ...]]) -> ndarray[float64]: ... @overload