diff options
| author | Bas van Beek <b.f.van.beek@vu.nl> | 2021-05-24 13:35:35 +0200 |
|---|---|---|
| committer | Bas van Beek <b.f.van.beek@vu.nl> | 2021-06-11 22:15:06 +0200 |
| commit | 4209558866c10eb0d528a6888b8297b405bae97e (patch) | |
| tree | e1d1b469914da8f18752a25dcb6adb5d73f45a03 | |
| parent | c633a13496e1681d9940227af12adf9190dabeb3 (diff) | |
| download | numpy-4209558866c10eb0d528a6888b8297b405bae97e.tar.gz | |
MAINT: Move 4 array constructors from `np.core._asarray` to `np.core.multiarray`
| -rw-r--r-- | numpy/__init__.pyi | 8 | ||||
| -rw-r--r-- | numpy/core/_asarray.pyi | 36 | ||||
| -rw-r--r-- | numpy/core/multiarray.pyi | 30 |
3 files changed, 35 insertions, 39 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index ade1a0abc..85ab4e8d8 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -252,10 +252,6 @@ from numpy.core.fromnumeric import ( ) from numpy.core._asarray import ( - asarray as asarray, - asanyarray as asanyarray, - ascontiguousarray as ascontiguousarray, - asfortranarray as asfortranarray, require as require, ) @@ -324,6 +320,10 @@ from numpy.core.multiarray import ( unpackbits as unpackbits, shares_memory as shares_memory, may_share_memory as may_share_memory, + asarray as asarray, + asanyarray as asanyarray, + ascontiguousarray as ascontiguousarray, + asfortranarray as asfortranarray, ) from numpy.core.numeric import ( diff --git a/numpy/core/_asarray.pyi b/numpy/core/_asarray.pyi index ee21fc0f1..1928cfe12 100644 --- a/numpy/core/_asarray.pyi +++ b/numpy/core/_asarray.pyi @@ -1,7 +1,7 @@ import sys from typing import TypeVar, Union, Iterable, overload -from numpy import ndarray, _OrderKACF +from numpy import ndarray from numpy.typing import ArrayLike, DTypeLike if sys.version_info >= (3, 8): @@ -11,40 +11,6 @@ else: _ArrayType = TypeVar("_ArrayType", bound=ndarray) -# TODO: The following functions are now defined in C, so should be defined -# in a (not yet existing) `multiarray.pyi`. -# (with the exception of `require`) - -def asarray( - a: object, - dtype: DTypeLike = ..., - order: _OrderKACF = ..., - *, - like: ArrayLike = ... -) -> ndarray: ... -@overload -def asanyarray( - a: _ArrayType, - dtype: None = ..., - order: _OrderKACF = ..., - *, - like: ArrayLike = ... -) -> _ArrayType: ... -@overload -def asanyarray( - a: object, - dtype: DTypeLike = ..., - order: _OrderKACF = ..., - *, - like: ArrayLike = ... -) -> ndarray: ... -def ascontiguousarray( - a: object, dtype: DTypeLike = ..., *, like: ArrayLike = ... -) -> ndarray: ... -def asfortranarray( - a: object, dtype: DTypeLike = ..., *, like: ArrayLike = ... -) -> ndarray: ... - _Requirements = Literal[ "C", "C_CONTIGUOUS", "CONTIGUOUS", "F", "F_CONTIGUOUS", "FORTRAN", diff --git a/numpy/core/multiarray.pyi b/numpy/core/multiarray.pyi index cd8761511..518843004 100644 --- a/numpy/core/multiarray.pyi +++ b/numpy/core/multiarray.pyi @@ -386,3 +386,33 @@ def may_share_memory( __b: object, max_work: Optional[int] = ..., ) -> bool: ... + +def asarray( + a: object, + dtype: DTypeLike = ..., + order: _OrderKACF = ..., + *, + like: ArrayLike = ... +) -> ndarray: ... +@overload +def asanyarray( + a: _ArrayType, + dtype: None = ..., + order: _OrderKACF = ..., + *, + like: ArrayLike = ... +) -> _ArrayType: ... +@overload +def asanyarray( + a: object, + dtype: DTypeLike = ..., + order: _OrderKACF = ..., + *, + like: ArrayLike = ... +) -> ndarray: ... +def ascontiguousarray( + a: object, dtype: DTypeLike = ..., *, like: ArrayLike = ... +) -> ndarray: ... +def asfortranarray( + a: object, dtype: DTypeLike = ..., *, like: ArrayLike = ... +) -> ndarray: ... |
