8000 ENH: Add annotations for `np.core.arrayprint` by BvB93 · Pull Request #18032 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Add annotations for np.core.arrayprint #18032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 19, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
MAINT: Added a type-alias for the floatmode annotations
Co-Authored-By: Eric Wieser <425260+eric-wieser@users.noreply.github.com>
  • Loading branch information
Bas van Beek and eric-wieser committed Dec 19, 2020
commit 05fa6e4bc219fb4db0808ef5cf9aed96c8ec0844
16 changes: 7 additions & 9 deletions numpy/core/arrayprint.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ if sys.version_info > (3, 8):
else:
from typing_extensions import Literal, TypedDict

_FloatMode = Literal["fixed", "unique", "maxprec", "maxprec_equal"]

class _FormatDict(TypedDict, total=False):
bool: Callable[[bool_], str]
int: Callable[[integer[Any]], str]
Expand Down Expand Up @@ -56,7 +58,7 @@ class _FormatOptions(TypedDict):
infstr: str
formatter: Optional[_FormatDict]
sign: Literal["-", "+", " "]
floatmode: Literal["fixed", "unique", "maxprec", "maxprec_equal"]
floatmode: _FloatMode
legacy: Literal[False, "1.13"]

def set_printoptions(
Expand All @@ -69,9 +71,7 @@ def set_printoptions(
infstr: Optional[str] = ...,
formatter: Optional[_FormatDict] = ...,
sign: Optional[Literal["-", "+", " "]] = ...,
floatmode: Optional[
Literal["fixed", "unique", "maxprec", "maxprec_equal"]
] = ...,
floatmode: Optional[_FloatMode] = ...,
*,
legacy: Optional[Literal[False, "1.13"]] = ...
) -> None: ...
Expand All @@ -83,15 +83,15 @@ def array2string(
suppress_small: Optional[bool] = ...,
separator: str = ...,
prefix: str = ...,
# NOTE With the `style` argument being deprecated,
# NOTE: With the `style` argument being deprecated,
# all arguments between `formatter` and `suffix` are de facto
# keyworld-only arguments
*,
formatter: Optional[_FormatDict] = ...,
threshold: Optional[int] = ...,
edgeitems: Optional[int] = ...,
sign: Optional[Literal["-", "+", " "]] = ...,
floatmode: Optional[Literal["fixed", "unique", "maxprec", "maxprec_equal"]] = ...,
floatmode: Optional[_FloatMode] = ...,
suffix: str = ...,
legacy: Optional[Literal[False, "1.13"]] = ...,
) -> str: ...
Expand Down Expand Up @@ -139,9 +139,7 @@ def printoptions(
infstr: Optional[str] = ...,
formatter: Optional[_FormatDict] = ...,
sign: Optional[Literal["-", "+", " "]] = ...,
floatmode: Optional[
Literal["fixed", "unique", "maxprec", "maxprec_equal"]
] = ...,
floatmode: Optional[_FloatMode] = ...,
*,
legacy: Optional[Literal[False, "1.13"]] = ...
) -> _GeneratorContextManager[_FormatOptions]: ...
0