Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
arrayprint.pyi159 linesDownload Raw Back to _core
1from collections.abc import Callable
2
3# Using a private class is by no means ideal, but it is simply a consequence
4# of a `contextlib.context` returning an instance of aforementioned class
5from contextlib import _GeneratorContextManager
6from typing import (
7    Any,
8    Final,
9    Literal,
10    SupportsIndex,
11    TypeAlias,
12    TypedDict,
13    type_check_only,
14)
15
16import numpy as np
17from numpy._typing import NDArray, _CharLike_co, _FloatLike_co
18
19__all__ = [
20    "array2string",
21    "array_repr",
22    "array_str",
23    "format_float_positional",
24    "format_float_scientific",
25    "get_printoptions",
26    "printoptions",
27    "set_printoptions",
28]
29
30###
31
32_FloatMode: TypeAlias = Literal["fixed", "unique", "maxprec", "maxprec_equal"]
33_LegacyNoStyle: TypeAlias = Literal["1.21", "1.25", "2.1", False]
34_Legacy: TypeAlias = Literal["1.13", _LegacyNoStyle]
35_Sign: TypeAlias = Literal["-", "+", " "]
36_Trim: TypeAlias = Literal["k", ".", "0", "-"]
37_ReprFunc: TypeAlias = Callable[[NDArray[Any]], str]
38
39@type_check_only
40class _FormatDict(TypedDict, total=False):
41    bool: Callable[[np.bool], str]
42    int: Callable[[np.integer], str]
43    timedelta: Callable[[np.timedelta64], str]
44    datetime: Callable[[np.datetime64], str]
45    float: Callable[[np.floating], str]
46    longfloat: Callable[[np.longdouble], str]
47    complexfloat: Callable[[np.complexfloating], str]
48    longcomplexfloat: Callable[[np.clongdouble], str]
49    void: Callable[[np.void], str]
50    numpystr: Callable[[_CharLike_co], str]
51    object: Callable[[object], str]
52    all: Callable[[object], str]
53    int_kind: Callable[[np.integer], str]
54    float_kind: Callable[[np.floating], str]
55    complex_kind: Callable[[np.complexfloating], str]
56    str_kind: Callable[[_CharLike_co], str]
57
58@type_check_only
59class _FormatOptions(TypedDict):
60    precision: int
61    threshold: int
62    edgeitems: int
63    linewidth: int
64    suppress: bool
65    nanstr: str
66    infstr: str
67    formatter: _FormatDict | None
68    sign: _Sign
69    floatmode: _FloatMode
70    legacy: _Legacy
71
72###
73
74__docformat__: Final = "restructuredtext"  # undocumented
75
76def set_printoptions(
77    precision: SupportsIndex | None = None,
78    threshold: int | None = None,
79    edgeitems: int | None = None,
80    linewidth: int | None = None,
81    suppress: bool | None = None,
82    nanstr: str | None = None,
83    infstr: str | None = None,
84    formatter: _FormatDict | None = None,
85    sign: _Sign | None = None,
86    floatmode: _FloatMode | None = None,
87    *,
88    legacy: _Legacy | None = None,
89    override_repr: _ReprFunc | None = None,
90) -> None: ...
91def get_printoptions() -> _FormatOptions: ...
92
93# public numpy export
94def array2string(
95    a: NDArray[Any],
96    max_line_width: int | None = None,
97    precision: SupportsIndex | None = None,
98    suppress_small: bool | None = None,
99    separator: str = " ",
100    prefix: str = "",
101    *,
102    formatter: _FormatDict | None = None,
103    threshold: int | None = None,
104    edgeitems: int | None = None,
105    sign: _Sign | None = None,
106    floatmode: _FloatMode | None = None,
107    suffix: str = "",
108    legacy: _Legacy | None = None,
109) -> str: ...
110
111def format_float_scientific(
112    x: _FloatLike_co,
113    precision: int | None = None,
114    unique: bool = True,
115    trim: _Trim = "k",
116    sign: bool = False,
117    pad_left: int | None = None,
118    exp_digits: int | None = None,
119    min_digits: int | None = None,
120) -> str: ...
121def format_float_positional(
122    x: _FloatLike_co,
123    precision: int | None = None,
124    unique: bool = True,
125    fractional: bool = True,
126    trim: _Trim = "k",
127    sign: bool = False,
128    pad_left: int | None = None,
129    pad_right: int | None = None,
130    min_digits: int | None = None,
131) -> str: ...
132def array_repr(
133    arr: NDArray[Any],
134    max_line_width: int | None = None,
135    precision: SupportsIndex | None = None,
136    suppress_small: bool | None = None,
137) -> str: ...
138def array_str(
139    a: NDArray[Any],
140    max_line_width: int | None = None,
141    precision: SupportsIndex | None = None,
142    suppress_small: bool | None = None,
143) -> str: ...
144def printoptions(
145    precision: SupportsIndex | None = ...,
146    threshold: int | None = ...,
147    edgeitems: int | None = ...,
148    linewidth: int | None = ...,
149    suppress: bool | None = ...,
150    nanstr: str | None = ...,
151    infstr: str | None = ...,
152    formatter: _FormatDict | None = ...,
153    sign: _Sign | None = None,
154    floatmode: _FloatMode | None = None,
155    *,
156    legacy: _Legacy | None = None,
157    override_repr: _ReprFunc | None = None,
158) -> _GeneratorContextManager[_FormatOptions]: ...
159 
codekingpro/portable-devtools · Team Ai