Skip to content
50 changes: 31 additions & 19 deletions src/numpy-stubs/@test/static/accept/lib_function_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -145,33 +145,45 @@ assert_type(np.median(AR_f8, keepdims=True), Any)
assert_type(np.median(AR_c16, axis=0), Any)
assert_type(np.median(AR_LIKE_f, out=AR_c16), _nt.Array[np.complex128])

assert_type(np.percentile(AR_f8, 50), np.floating)
assert_type(np.percentile(AR_c16, 50), np.complexfloating)
# percentile
assert_type(np.percentile(AR_f8, 50), np.float64)
assert_type(np.percentile(AR_f8, 50, axis=1), _nt.Array[np.float64])
assert_type(np.percentile(AR_f8, 50, axis=(1, 0)), _nt.Array[np.float64])
assert_type(np.percentile(AR_f8, 50, keepdims=True), _nt.Array[np.float64])
assert_type(np.percentile(AR_f8, 50, axis=0, keepdims=True), _nt.Array[np.float64])
assert_type(np.percentile(AR_c16, 50), np.complex128)
assert_type(np.percentile(AR_m, 50), np.timedelta64)
assert_type(np.percentile(AR_M, 50, overwrite_input=True), np.datetime64)
assert_type(np.percentile(AR_O, 50), Any)
assert_type(np.percentile(AR_f8, [50]), _nt.Array[np.floating])
assert_type(np.percentile(AR_c16, [50]), _nt.Array[np.complexfloating])
assert_type(np.percentile(AR_f8, [50]), _nt.Array[np.float64])
assert_type(np.percentile(AR_f8, [50], axis=1), _nt.Array[np.float64])
assert_type(np.percentile(AR_f8, [50], keepdims=True), _nt.Array[np.float64])
assert_type(np.percentile(AR_c16, [50]), _nt.Array[np.complex128])
assert_type(np.percentile(AR_m, [50]), _nt.Array[np.timedelta64])
assert_type(np.percentile(AR_M, [50], method="nearest"), _nt.Array[np.datetime64])
assert_type(np.percentile(AR_O, [50]), _nt.Array[np.object_])
assert_type(np.percentile(AR_f8, [50], keepdims=True), Any)
assert_type(np.percentile(AR_f8, [50], axis=[1]), Any)
assert_type(np.percentile(AR_f8, [50], keepdims=True), _nt.Array[np.float64])
assert_type(np.percentile(AR_f8, [50], out=AR_c16), _nt.Array[np.complex128])

assert_type(np.quantile(AR_f8, 0.5), np.floating)
assert_type(np.quantile(AR_c16, 0.5), np.complexfloating)
assert_type(np.quantile(AR_m, 0.5), np.timedelta64)
assert_type(np.quantile(AR_M, 0.5, overwrite_input=True), np.datetime64)
assert_type(np.quantile(AR_O, 0.5), Any)
assert_type(np.quantile(AR_f8, [0.5]), _nt.Array[np.floating])
assert_type(np.quantile(AR_c16, [0.5]), _nt.Array[np.complexfloating])
assert_type(np.quantile(AR_m, [0.5]), _nt.Array[np.timedelta64])
assert_type(np.quantile(AR_M, [0.5], method="nearest"), _nt.Array[np.datetime64])
assert_type(np.quantile(AR_O, [0.5]), _nt.Array[np.object_])
assert_type(np.quantile(AR_f8, [0.5], keepdims=True), Any)
assert_type(np.quantile(AR_f8, [0.5], axis=[1]), Any)
assert_type(np.quantile(AR_f8, [0.5], out=AR_c16), _nt.Array[np.complex128])
# quantile
assert_type(np.quantile(AR_f8, 0.50), np.float64)
assert_type(np.quantile(AR_f8, 0.50, axis=1), _nt.Array[np.float64])
assert_type(np.quantile(AR_f8, 0.50, axis=(1, 0)), _nt.Array[np.float64])
assert_type(np.quantile(AR_f8, 0.50, keepdims=True), _nt.Array[np.float64])
assert_type(np.quantile(AR_f8, 0.50, axis=0, keepdims=True), _nt.Array[np.float64])
assert_type(np.quantile(AR_c16, 0.50), np.complex128)
assert_type(np.quantile(AR_m, 0.50), np.timedelta64)
assert_type(np.quantile(AR_M, 0.50, overwrite_input=True), np.datetime64)
assert_type(np.quantile(AR_O, 0.50), Any)
assert_type(np.quantile(AR_f8, [0.50]), _nt.Array[np.float64])
assert_type(np.quantile(AR_f8, [0.50], axis=1), _nt.Array[np.float64])
assert_type(np.quantile(AR_f8, [0.50], keepdims=True), _nt.Array[np.float64])
assert_type(np.quantile(AR_c16, [0.50]), _nt.Array[np.complex128])
assert_type(np.quantile(AR_m, [0.50]), _nt.Array[np.timedelta64])
assert_type(np.quantile(AR_M, [0.50], method="nearest"), _nt.Array[np.datetime64])
assert_type(np.quantile(AR_O, [0.50]), _nt.Array[np.object_])
assert_type(np.quantile(AR_f8, [0.50], keepdims=True), _nt.Array[np.float64])
assert_type(np.quantile(AR_f8, [0.50], out=AR_c16), _nt.Array[np.complex128])

assert_type(np.trapezoid(AR_LIKE_i), np.float64)
assert_type(np.trapezoid(AR_LIKE_f), np.float64)
Expand Down
8 changes: 4 additions & 4 deletions src/numpy-stubs/@test/static/reject/lib_function_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ np.average(AR_m) # type: ignore[arg-type] # pyright: ignore[reportArgumentType
np.median(AR_M) # type: ignore[arg-type] # pyright: ignore[reportArgumentType, reportCallIssue]
np.percentile(AR_f8, 50j) # type: ignore[call-overload] # pyright: ignore[reportArgumentType, reportCallIssue]
np.quantile(AR_f8, 0.5j) # type: ignore[call-overload] # pyright: ignore[reportArgumentType, reportCallIssue]
np.percentile(AR_f8, 50, interpolation="bob") # type: ignore[call-overload] # pyright: ignore[reportArgumentType, reportCallIssue]
np.quantile(AR_f8, 0.5, interpolation="bob") # type: ignore[call-overload] # pyright: ignore[reportArgumentType, reportCallIssue]
np.percentile(AR_f8, 50, interpolation="bob") # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
np.quantile(AR_f8, 0.5, interpolation="bob") # type: ignore[call-overload] # pyright: ignore[reportCallIssue]

np.cov(AR_m) # type: ignore[arg-type] # pyright: ignore[reportArgumentType, reportCallIssue]
np.cov(AR_O) # type: ignore[arg-type] # pyright: ignore[reportArgumentType, reportCallIssue]

np.corrcoef(AR_m) # type: ignore[arg-type] # pyright: ignore[reportArgumentType, reportCallIssue]
np.corrcoef(AR_O) # type: ignore[arg-type] # pyright: ignore[reportArgumentType, reportCallIssue]
np.corrcoef(AR_f8, bias=True) # type: ignore[call-overload] # pyright: ignore[reportArgumentType, reportCallIssue]
np.corrcoef(AR_f8, ddof=2) # type: ignore[call-overload] # pyright: ignore[reportArgumentType, reportCallIssue]
np.corrcoef(AR_f8, bias=True) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
np.corrcoef(AR_f8, ddof=2) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]

np.blackman(1j) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
np.bartlett(1j) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
Expand Down
2 changes: 1 addition & 1 deletion src/numpy-stubs/@test/static/reject/npyio.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pathlib_path: pathlib.Path
str_file: IO[str]
AR_i8: _nt.Array[np.int64]

np.save(bytes_path, AR_i8) # type: ignore[call-overload] # pyright: ignore[reportArgumentType]
np.save(bytes_path, AR_i8) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
np.savez(bytes_path, AR_i8) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
np.savez_compressed(bytes_path, AR_i8) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]

Expand Down
6 changes: 2 additions & 4 deletions src/numpy-stubs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ from .lib import scimath as emath
from .lib._arraypad_impl import pad
from .lib._arraysetops_impl import (
ediff1d,
in1d,
intersect1d,
isin,
setdiff1d,
Expand Down Expand Up @@ -399,7 +398,6 @@ from .lib._function_base_impl import (
sinc,
sort_complex,
trapezoid,
trapz,
trim_zeros,
unwrap,
vectorize,
Expand Down Expand Up @@ -548,13 +546,13 @@ __all__ = [ # noqa: RUF022
# lib._arraypad_impl.*
"pad",
# lib._arraysetops_impl.*
"ediff1d", "in1d", "intersect1d", "isin", "setdiff1d", "setxor1d", "union1d", "unique", "unique_all",
"ediff1d", "intersect1d", "isin", "setdiff1d", "setxor1d", "union1d", "unique", "unique_all",
"unique_counts", "unique_inverse", "unique_values",
# lib._function_base_impl.*
"angle", "append", "asarray_chkfinite", "average", "bartlett", "bincount", "blackman", "copy", "corrcoef", "cov",
"delete", "diff", "digitize", "extract", "flip", "gradient", "hamming", "hanning", "i0", "insert", "interp",
"iterable", "kaiser", "median", "meshgrid", "percentile", "piecewise", "place", "quantile", "rot90", "select",
"sinc", "sort_complex", "trapezoid", "trapz", "trim_zeros", "unwrap", "vectorize",
"sinc", "sort_complex", "trapezoid", "trim_zeros", "unwrap", "vectorize",
# lib._histograms_impl.*
"histogram", "histogram_bin_edges", "histogramdd",
# lib._index_tricks_impl.*
Expand Down
14 changes: 1 addition & 13 deletions src/numpy-stubs/lib/_arraysetops_impl.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from typing import Any, Generic, Literal as L, NamedTuple, SupportsIndex as CanIndex, TypeAlias, overload
from typing_extensions import TypeVar, deprecated
from typing_extensions import TypeVar

import _numtype as _nt
import numpy as np
from numpy._typing import ArrayLike, _ArrayLike

__all__ = [
"ediff1d",
"in1d",
"intersect1d",
"isin",
"setdiff1d",
Expand Down Expand Up @@ -585,14 +584,3 @@ def isin(
*,
kind: L["sort", "table"] | None = None,
) -> _nt.Array[np.bool]: ...

#
@deprecated("Use 'isin' instead")
def in1d(
ar1: ArrayLike,
ar2: ArrayLike,
assume_unique: bool = False,
invert: bool = False,
*,
kind: L["sort", "table"] | None = None,
) -> _nt.Array1D[np.bool]: ...
Loading