summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-04-25 14:21:49 +0200
committerBas van Beek <b.f.van.beek@vu.nl>2021-04-26 16:53:56 +0200
commitcf68ebfaaa3d1f6d84029da033e78c785322aac3 (patch)
tree925fbb7cb9db16a90cf25064ae1093df76bf972c /numpy
parentf71c496ddc7caa2a47b2750cce455f6129def261 (diff)
downloadnumpy-cf68ebfaaa3d1f6d84029da033e78c785322aac3.tar.gz
MAINT: Import `np.lib`-based functions from aforementioned namespace
Diffstat (limited to 'numpy')
-rw-r--r--numpy/__init__.pyi333
-rw-r--r--numpy/lib/stride_tricks.pyi4
-rw-r--r--numpy/lib/twodim_base.pyi17
3 files changed, 200 insertions, 154 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index 09f214602..5c7a3c7e4 100644
--- a/numpy/__init__.pyi
+++ b/numpy/__init__.pyi
@@ -346,6 +346,69 @@ from numpy.lib import (
emath as emath,
)
+from numpy.lib.arraypad import (
+ pad as pad,
+)
+
+from numpy.lib.arraysetops import (
+ ediff1d as ediff1d,
+ intersect1d as intersect1d,
+ setxor1d as setxor1d,
+ union1d as union1d,
+ setdiff1d as setdiff1d,
+ unique as unique,
+ in1d as in1d,
+ isin as isin,
+)
+
+from numpy.lib.arrayterator import (
+ Arrayterator as Arrayterator,
+)
+
+from numpy.lib.function_base import (
+ select as select,
+ piecewise as piecewise,
+ trim_zeros as trim_zeros,
+ copy as copy,
+ iterable as iterable,
+ percentile as percentile,
+ diff as diff,
+ gradient as gradient,
+ angle as angle,
+ unwrap as unwrap,
+ sort_complex as sort_complex,
+ disp as disp,
+ flip as flip,
+ rot90 as rot90,
+ extract as extract,
+ place as place,
+ asarray_chkfinite as asarray_chkfinite,
+ average as average,
+ bincount as bincount,
+ digitize as digitize,
+ cov as cov,
+ corrcoef as corrcoef,
+ msort as msort,
+ median as median,
+ sinc as sinc,
+ hamming as hamming,
+ hanning as hanning,
+ bartlett as bartlett,
+ blackman as blackman,
+ kaiser as kaiser,
+ trapz as trapz,
+ i0 as i0,
+ add_newdoc as add_newdoc,
+ add_docstring as add_docstring,
+ meshgrid as meshgrid,
+ delete as delete,
+ insert as insert,
+ append as append,
+ interp as interp,
+ add_newdoc_ufunc as add_newdoc_ufunc,
+ quantile as quantile,
+)
+
from numpy.lib.index_tricks import (
ravel_multi_index as ravel_multi_index,
unravel_index as unravel_index,
@@ -361,12 +424,131 @@ from numpy.lib.index_tricks import (
diag_indices_from as diag_indices_from,
)
+from numpy.lib.nanfunctions import (
+ nansum as nansum,
+ nanmax as nanmax,
+ nanmin as nanmin,
+ nanargmax as nanargmax,
+ nanargmin as nanargmin,
+ nanmean as nanmean,
+ nanmedian as nanmedian,
+ nanpercentile as nanpercentile,
+ nanvar as nanvar,
+ nanstd as nanstd,
+ nanprod as nanprod,
+ nancumsum as nancumsum,
+ nancumprod as nancumprod,
+ nanquantile as nanquantile,
+)
+
+from numpy.lib.npyio import (
+ savetxt as savetxt,
+ loadtxt as loadtxt,
+ genfromtxt as genfromtxt,
+ recfromtxt as recfromtxt,
+ recfromcsv as recfromcsv,
+ load as load,
+ loads as loads,
+ save as save,
+ savez as savez,
+ savez_compressed as savez_compressed,
+ packbits as packbits,
+ unpackbits as unpackbits,
+ fromregex as fromregex,
+)
+
+from numpy.lib.polynomial import (
+ poly as poly,
+ roots as roots,
+ polyint as polyint,
+ polyder as polyder,
+ polyadd as polyadd,
+ polysub as polysub,
+ polymul as polymul,
+ polydiv as polydiv,
+ polyval as polyval,
+ polyfit as polyfit,
+)
+
+from numpy.lib.shape_base import (
+ column_stack as column_stack,
+ row_stack as row_stack,
+ dstack as dstack,
+ array_split as array_split,
+ split as split,
+ hsplit as hsplit,
+ vsplit as vsplit,
+ dsplit as dsplit,
+ apply_over_axes as apply_over_axes,
+ expand_dims as expand_dims,
+ apply_along_axis as apply_along_axis,
+ kron as kron,
+ tile as tile,
+ get_array_wrap as get_array_wrap,
+ take_along_axis as take_along_axis,
+ put_along_axis as put_along_axis,
+)
+
+from numpy.lib.stride_tricks import (
+ broadcast_to as broadcast_to,
+ broadcast_arrays as broadcast_arrays,
+ broadcast_shapes as broadcast_shapes,
+)
+
+from numpy.lib.twodim_base import (
+ diag as diag,
+ diagflat as diagflat,
+ eye as eye,
+ fliplr as fliplr,
+ flipud as flipud,
+ tri as tri,
+ triu as triu,
+ tril as tril,
+ vander as vander,
+ histogram2d as histogram2d,
+ mask_indices as mask_indices,
+ tril_indices as tril_indices,
+ tril_indices_from as tril_indices_from,
+ triu_indices as triu_indices,
+ triu_indices_from as triu_indices_from,
+)
+
+from numpy.lib.type_check import (
+ mintypecode as mintypecode,
+ asfarray as asfarray,
+ real as real,
+ imag as imag,
+ iscomplex as iscomplex,
+ isreal as isreal,
+ iscomplexobj as iscomplexobj,
+ isrealobj as isrealobj,
+ nan_to_num as nan_to_num,
+ real_if_close as real_if_close,
+ typename as typename,
+ common_type as common_type,
+)
+
from numpy.lib.ufunclike import (
fix as fix,
isposinf as isposinf,
isneginf as isneginf,
)
+from numpy.lib.utils import (
+ issubclass_ as issubclass_,
+ issubsctype as issubsctype,
+ issubdtype as issubdtype,
+ deprecate as deprecate,
+ deprecate_with_doc as deprecate_with_doc,
+ get_include as get_include,
+ info as info,
+ source as source,
+ who as who,
+ lookfor as lookfor,
+ byte_bounds as byte_bounds,
+ safe_eval as safe_eval,
+)
+
__all__: List[str]
__path__: List[str]
__version__: str
@@ -652,154 +834,19 @@ class vectorize:
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
# Placeholders for Python-based functions
-def angle(z, deg=...): ...
-def append(arr, values, axis=...): ...
-def apply_along_axis(func1d, axis, arr, *args, **kwargs): ...
-def apply_over_axes(func, a, axes): ...
-def array_split(ary, indices_or_sections, axis=...): ...
-def asarray_chkfinite(a, dtype=..., order=...): ...
-def asfarray(a, dtype=...): ...
def asmatrix(data, dtype=...): ...
def asscalar(a): ...
-def average(a, axis=..., weights=..., returned=...): ...
-def bartlett(M): ...
-def blackman(M): ...
-def bmat(obj, ldict=..., gdict=...): ...
-def broadcast_arrays(*args, subok=...): ...
-def broadcast_to(array, shape, subok=...): ...
-def byte_bounds(a): ...
-def column_stack(tup): ...
-def common_type(*arrays): ...
-def copy(a, order=..., subok=...): ...
-def corrcoef(x, y=..., rowvar=..., bias=..., ddof=..., *, dtype=...): ...
-def cov(m, y=..., rowvar=..., bias=..., ddof=..., fweights=..., aweights=..., *, dtype=...): ...
def cumproduct(*args, **kwargs): ...
-def delete(arr, obj, axis=...): ...
-def deprecate(*args, **kwargs): ...
-def deprecate_with_doc(msg): ...
-def diag(v, k=...): ...
-def diagflat(v, k=...): ...
-def diff(a, n=..., axis=..., prepend=..., append=...): ...
-def digitize(x, bins, right=...): ...
-def disp(mesg, device=..., linefeed=...): ...
-def dsplit(ary, indices_or_sections): ...
-def dstack(tup): ...
-def ediff1d(ary, to_end=..., to_begin=...): ...
-def expand_dims(a, axis): ...
-def extract(condition, arr): ...
-def flip(m, axis=...): ...
-def fliplr(m): ...
-def flipud(m): ...
-def fromregex(file, regexp, dtype, encoding=...): ...
-def genfromtxt(fname, dtype=..., comments=..., delimiter=..., skip_header=..., skip_footer=..., converters=..., missing_values=..., filling_values=..., usecols=..., names=..., excludelist=..., deletechars=..., replace_space=..., autostrip=..., case_sensitive=..., defaultfmt=..., unpack=..., usemask=..., loose=..., invalid_raise=..., max_rows=..., encoding=..., *, like=...): ...
-def get_include(): ...
-def gradient(f, *varargs, axis=..., edge_order=...): ...
-def hamming(M): ...
-def hanning(M): ...
def histogram(a, bins=..., range=..., normed=..., weights=..., density=...): ...
-def histogram2d(x, y, bins=..., range=..., normed=..., weights=..., density=...): ...
def histogram_bin_edges(a, bins=..., range=..., weights=...): ...
def histogramdd(sample, bins=..., range=..., normed=..., weights=..., density=...): ...
-def hsplit(ary, indices_or_sections): ...
-def i0(x): ...
-def imag(val): ...
-def in1d(ar1, ar2, assume_unique=..., invert=...): ...
-def info(object=..., maxwidth=..., output=..., toplevel=...): ...
-def insert(arr, obj, values, axis=...): ...
-def interp(x, xp, fp, left=..., right=..., period=...): ...
-def intersect1d(ar1, ar2, assume_unique=..., return_indices=...): ...
-def iscomplex(x): ...
-def iscomplexobj(x): ...
-def isin(element, test_elements, assume_unique=..., invert=...): ...
-def isreal(x): ...
-def isrealobj(x): ...
-def iterable(y): ...
-def kaiser(M, beta): ...
-def kron(a, b): ...
-def load(file, mmap_mode=..., allow_pickle=..., fix_imports=..., encoding=...): ...
-def loads(*args, **kwargs): ...
-def loadtxt(fname, dtype=..., comments=..., delimiter=..., converters=..., skiprows=..., usecols=..., unpack=..., ndmin=..., encoding=..., max_rows=..., *, like=...): ...
-def lookfor(what, module=..., import_modules=..., regenerate=..., output=...): ...
-def mafromtxt(fname, **kwargs): ...
-def mask_indices(n, mask_func, k=...): ...
def mat(data, dtype=...): ...
def max(a, axis=..., out=..., keepdims=..., initial=..., where=...): ...
-def median(a, axis=..., out=..., overwrite_input=..., keepdims=...): ...
-def meshgrid(*xi, copy=..., sparse=..., indexing=...): ...
def min(a, axis=..., out=..., keepdims=..., initial=..., where=...): ...
-def mintypecode(typechars, typeset=..., default=...): ...
-def msort(a): ...
-def nan_to_num(x, copy=..., nan=..., posinf=..., neginf=...): ...
-def nanargmax(a, axis=...): ...
-def nanargmin(a, axis=...): ...
-def nancumprod(a, axis=..., dtype=..., out=...): ...
-def nancumsum(a, axis=..., dtype=..., out=...): ...
-def nanmax(a, axis=..., out=..., keepdims=...): ...
-def nanmean(a, axis=..., dtype=..., out=..., keepdims=...): ...
-def nanmedian(a, axis=..., out=..., overwrite_input=..., keepdims=...): ...
-def nanmin(a, axis=..., out=..., keepdims=...): ...
-def nanpercentile(a, q, axis=..., out=..., overwrite_input=..., interpolation=..., keepdims=...): ...
-def nanprod(a, axis=..., dtype=..., out=..., keepdims=...): ...
-def nanquantile(a, q, axis=..., out=..., overwrite_input=..., interpolation=..., keepdims=...): ...
-def nanstd(a, axis=..., dtype=..., out=..., ddof=..., keepdims=...): ...
-def nansum(a, axis=..., dtype=..., out=..., keepdims=...): ...
-def nanvar(a, axis=..., dtype=..., out=..., ddof=..., keepdims=...): ...
-def ndfromtxt(fname, **kwargs): ...
-def pad(array, pad_width, mode=..., **kwargs): ...
-def percentile(a, q, axis=..., out=..., overwrite_input=..., interpolation=..., keepdims=...): ...
-def piecewise(x, condlist, funclist, *args, **kw): ...
-def place(arr, mask, vals): ...
-def poly(seq_of_zeros): ...
-def polyadd(a1, a2): ...
-def polyder(p, m=...): ...
-def polydiv(u, v): ...
-def polyfit(x, y, deg, rcond=..., full=..., w=..., cov=...): ...
-def polyint(p, m=..., k=...): ...
-def polymul(a1, a2): ...
-def polysub(a1, a2): ...
-def polyval(p, x): ...
def product(*args, **kwargs): ...
-def put_along_axis(arr, indices, values, axis): ...
-def quantile(a, q, axis=..., out=..., overwrite_input=..., interpolation=..., keepdims=...): ...
-def real(val): ...
-def real_if_close(a, tol=...): ...
-def recfromcsv(fname, **kwargs): ...
-def recfromtxt(fname, **kwargs): ...
-def roots(p): ...
-def rot90(m, k=..., axes=...): ...
def round(a, decimals=..., out=...): ...
def round_(a, decimals=..., out=...): ...
-def row_stack(tup): ...
-def save(file, arr, allow_pickle=..., fix_imports=...): ...
-def savetxt(fname, X, fmt=..., delimiter=..., newline=..., header=..., footer=..., comments=..., encoding=...): ...
-def savez(file, *args, **kwds): ...
-def savez_compressed(file, *args, **kwds): ...
-def select(condlist, choicelist, default=...): ...
-def setdiff1d(ar1, ar2, assume_unique=...): ...
-def setxor1d(ar1, ar2, assume_unique=...): ...
def show_config(): ...
-def sinc(x): ...
-def sort_complex(a): ...
-def source(object, output=...): ...
-def split(ary, indices_or_sections, axis=...): ...
-def take_along_axis(arr, indices, axis): ...
-def tile(A, reps): ...
-def trapz(y, x=..., dx=..., axis=...): ...
-def tri(N, M=..., k=..., dtype=..., *, like=...): ...
-def tril(m, k=...): ...
-def tril_indices(n, k=..., m=...): ...
-def tril_indices_from(arr, k=...): ...
-def trim_zeros(filt, trim=...): ...
-def triu(m, k=...): ...
-def triu_indices(n, k=..., m=...): ...
-def triu_indices_from(arr, k=...): ...
-def typename(char): ...
-def union1d(ar1, ar2): ...
-def unique(ar, return_index=..., return_inverse=..., return_counts=..., axis=...): ...
-def unwrap(p, discont=..., axis=...): ...
-def vander(x, N=..., increasing=...): ...
-def vsplit(ary, indices_or_sections): ...
-def who(vardict=...): ...
# Placeholders for C-based functions
# TODO: Sort out which parameters are positional-only
@@ -807,7 +854,6 @@ def who(vardict=...): ...
def arange(stop, dtype=..., *, like=...): ...
@overload
def arange(start, stop, step=..., dtype=..., *, like=...): ...
-def bincount(x, weights=..., minlength=...): ...
def busday_count(
begindates,
enddates,
@@ -848,13 +894,11 @@ def lexsort(keys, axis=...): ...
def may_share_memory(a, b, max_work=...): ...
def min_scalar_type(a): ...
def nested_iters(*args, **kwargs): ... # TODO: Sort out parameters
-def packbits(a, axis=..., bitorder=...): ...
def promote_types(type1, type2): ...
def putmask(a, mask, values): ...
def result_type(*arrays_and_dtypes): ...
def seterrobj(errobj): ...
def shares_memory(a, b, max_work=...): ...
-def unpackbits(a, axis=..., count=..., bitorder=...): ...
def vdot(a, b): ...
@overload
def where(__condition): ...
@@ -865,17 +909,6 @@ _NdArraySubClass = TypeVar("_NdArraySubClass", bound=ndarray)
_DTypeScalar_co = TypeVar("_DTypeScalar_co", covariant=True, bound=generic)
_ByteOrder = Literal["S", "<", ">", "=", "|", "L", "B", "N", "I"]
-# TODO: Move to `np.lib.twodim_base`
-def eye(
- N: int,
- M: Optional[int] = ...,
- k: int = ...,
- dtype: DTypeLike = ...,
- order: _OrderCF = ...,
- *,
- like: Optional[ArrayLike] = ...
-) -> ndarray[Any, Any]: ...
-
class dtype(Generic[_DTypeScalar_co]):
names: Optional[Tuple[str, ...]]
# Overload for subclass of generic
@@ -3165,8 +3198,6 @@ def empty(
like: ArrayLike = ...,
) -> ndarray: ...
-def broadcast_shapes(*args: _ShapeLike) -> _Shape: ...
-
#
# Constants
#
diff --git a/numpy/lib/stride_tricks.pyi b/numpy/lib/stride_tricks.pyi
index 5e49eff6d..d2e744b5a 100644
--- a/numpy/lib/stride_tricks.pyi
+++ b/numpy/lib/stride_tricks.pyi
@@ -1,5 +1,7 @@
from typing import Any, List
+from numpy.typing import _ShapeLike, _Shape
+
__all__: List[str]
class DummyArray:
@@ -10,5 +12,5 @@ class DummyArray:
def as_strided(x, shape=..., strides=..., subok=..., writeable=...): ...
def sliding_window_view(x, window_shape, axis=..., *, subok=..., writeable=...): ...
def broadcast_to(array, shape, subok=...): ...
-def broadcast_shapes(*args): ...
+def broadcast_shapes(*args: _ShapeLike) -> _Shape: ...
def broadcast_arrays(*args, subok=...): ...
diff --git a/numpy/lib/twodim_base.pyi b/numpy/lib/twodim_base.pyi
index 44e15308e..79b9511b8 100644
--- a/numpy/lib/twodim_base.pyi
+++ b/numpy/lib/twodim_base.pyi
@@ -1,10 +1,23 @@
-from typing import List
+from typing import List, Optional, Any
+
+from numpy import ndarray, _OrderCF
+from numpy.typing import ArrayLike, DTypeLike
__all__: List[str]
def fliplr(m): ...
def flipud(m): ...
-def eye(N, M=..., k=..., dtype = ..., order=..., *, like=...): ...
+
+def eye(
+ N: int,
+ M: Optional[int] = ...,
+ k: int = ...,
+ dtype: DTypeLike = ...,
+ order: _OrderCF = ...,
+ *,
+ like: Optional[ArrayLike] = ...
+) -> ndarray[Any, Any]: ...
+
def diag(v, k=...): ...
def diagflat(v, k=...): ...
def tri(N, M=..., k=..., dtype = ..., *, like=...): ...