Skip to content
This repository was archived by the owner on Jun 10, 2020. It is now read-only.

ENH: add integer constants #52

Merged
merged 1 commit into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion numpy-stubs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,10 @@ def isclose(
def array_equal(a1: _ArrayLike, a2: _ArrayLike) -> bool: ...
def array_equiv(a1: _ArrayLike, a2: _ArrayLike) -> bool: ...

# Numerical constants
#
# Constants
#

Inf: float
Infinity: float
NAN: float
Expand All @@ -587,5 +590,33 @@ infty: float
nan: float
pi: float

ALLOW_THREADS: int
BUFSIZE: int
CLIP: int
ERR_CALL: int
ERR_DEFAULT: int
ERR_IGNORE: int
ERR_LOG: int
ERR_PRINT: int
ERR_RAISE: int
ERR_WARN: int
FLOATING_POINT_SUPPORT: int
FPE_DIVIDEBYZERO: int
FPE_INVALID: int
FPE_OVERFLOW: int
FPE_UNDERFLOW: int
MAXDIMS: int
MAY_SHARE_BOUNDS: int
MAY_SHARE_EXACT: int
RAISE: int
SHIFT_DIVIDEBYZERO: int
SHIFT_INVALID: int
SHIFT_OVERFLOW: int
SHIFT_UNDERFLOW: int
UFUNC_BUFSIZE_DEFAULT: int
WRAP: int
little_endian: int
tracemalloc_domain: int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't supposed to show up in the main namespace, release notes explicitly say np.lib.tracemalloc_domain - oh the namespace pollution :(


# TODO(shoyer): remove when the full numpy namespace is defined
def __getattr__(name: str) -> Any: ...
28 changes: 28 additions & 0 deletions tests/reveal/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,31 @@
reveal_type(np.infty) # E: float
reveal_type(np.nan) # E: float
reveal_type(np.pi) # E: float

reveal_type(np.ALLOW_THREADS) # E: int
reveal_type(np.BUFSIZE) # E: int
reveal_type(np.CLIP) # E: int
reveal_type(np.ERR_CALL) # E: int
reveal_type(np.ERR_DEFAULT) # E: int
reveal_type(np.ERR_IGNORE) # E: int
reveal_type(np.ERR_LOG) # E: int
reveal_type(np.ERR_PRINT) # E: int
reveal_type(np.ERR_RAISE) # E: int
reveal_type(np.ERR_WARN) # E: int
reveal_type(np.FLOATING_POINT_SUPPORT) # E: int
reveal_type(np.FPE_DIVIDEBYZERO) # E: int
reveal_type(np.FPE_INVALID) # E: int
reveal_type(np.FPE_OVERFLOW) # E: int
reveal_type(np.FPE_UNDERFLOW) # E: int
reveal_type(np.MAXDIMS) # E: int
reveal_type(np.MAY_SHARE_BOUNDS) # E: int
reveal_type(np.MAY_SHARE_EXACT) # E: int
reveal_type(np.RAISE) # E: int
reveal_type(np.SHIFT_DIVIDEBYZERO) # E: int
reveal_type(np.SHIFT_INVALID) # E: int
reveal_type(np.SHIFT_OVERFLOW) # E: int
reveal_type(np.SHIFT_UNDERFLOW) # E: int
reveal_type(np.UFUNC_BUFSIZE_DEFAULT) # E: int
reveal_type(np.WRAP) # E: int
reveal_type(np.little_endian) # E: int
reveal_type(np.tracemalloc_domain) # E: int