1
1
from collections .abc import Callable
2
2
from contextlib import _GeneratorContextManager
3
- from typing import Any , Final , Literal , SupportsIndex , TypeAlias , TypedDict , overload , type_check_only
3
+ from typing import Final , Literal , SupportsIndex , TypeAlias , TypedDict , overload , type_check_only
4
4
from typing_extensions import deprecated
5
5
6
+ import _numtype as _nt
6
7
import numpy as np
7
8
from numpy ._globals import _NoValueType
8
- from numpy ._typing import NDArray , _CharLike_co , _FloatLike_co
9
+ from numpy ._typing import _CharLike_co , _FloatLike_co
9
10
10
11
__all__ = [
11
12
"array2string" ,
@@ -25,7 +26,7 @@ _Sign: TypeAlias = Literal["-", "+", " "]
25
26
_Trim : TypeAlias = Literal ["k" , "." , "0" , "-" ]
26
27
_Legacy : TypeAlias = Literal ["1.13" , "1.21" , "1.25" , "2.1" , False ]
27
28
_LegacyNoStyle : TypeAlias = Literal ["1.21" , "1.25" , "2.1" , False ]
28
- _ReprFunc : TypeAlias = Callable [[NDArray [ Any ] ], str ]
29
+ _ReprFunc : TypeAlias = Callable [[_nt . Array ], str ]
29
30
30
31
@type_check_only
31
32
class _FormatDict (TypedDict , total = False ):
@@ -104,7 +105,7 @@ def printoptions(
104
105
# public numpy export
105
106
@overload # no style
106
107
def array2string (
107
- a : NDArray [ Any ] ,
108
+ a : _nt . Array ,
108
109
max_line_width : int | None = None ,
109
110
precision : SupportsIndex | None = None ,
110
111
suppress_small : bool | None = None ,
@@ -122,7 +123,7 @@ def array2string(
122
123
) -> str : ...
123
124
@overload # style=<given> (positional), legacy="1.13"
124
125
def array2string (
125
- a : NDArray [ Any ] ,
126
+ a : _nt . Array ,
126
127
max_line_width : int | None ,
127
128
precision : SupportsIndex | None ,
128
129
suppress_small : bool | None ,
@@ -140,7 +141,7 @@ def array2string(
140
141
) -> str : ...
141
142
@overload # style=<given> (keyword), legacy="1.13"
142
143
def array2string (
143
- a : NDArray [ Any ] ,
144
+ a : _nt . Array ,
144
145
max_line_width : int | None = None ,
145
146
precision : SupportsIndex | None = None ,
146
147
suppress_small : bool | None = None ,
@@ -159,7 +160,7 @@ def array2string(
159
160
@overload # style=<given> (positional), legacy!="1.13"
160
161
@deprecated ("'style' argument is deprecated and no longer functional except in 1.13 'legacy' mode" )
161
162
def array2string (
162
- a : NDArray [ Any ] ,
163
+ a : _nt . Array ,
163
164
max_line_width : int | None ,
164
165
precision : SupportsIndex | None ,
165
166
suppress_small : bool | None ,
@@ -178,7 +179,7 @@ def array2string(
178
179
@overload # style=<given> (keyword), legacy="1.13"
179
180
@deprecated ("'style' argument is deprecated and no longer functional except in 1.13 'legacy' mode" )
180
181
def array2string (
181
- a : NDArray [ Any ] ,
182
+ a : _nt . Array ,
182
183
max_line_width : int | None = None ,
183
184
precision : SupportsIndex | None = None ,
184
185
suppress_small : bool | None = None ,
@@ -222,15 +223,15 @@ def format_float_positional(
222
223
223
224
# public numpy export
224
225
def array_repr (
225
- arr : NDArray [ Any ] ,
226
+ arr : _nt . Array ,
226
227
max_line_width : int | None = None ,
227
228
precision : SupportsIndex | None = None ,
228
229
suppress_small : bool | None = None ,
229
230
) -> str : ...
230
231
231
232
# public numpy export
232
233
def array_str (
233
- a : NDArray [ Any ] ,
234
+ a : _nt . Array ,
234
235
max_line_width : int | None = None ,
235
236
precision : SupportsIndex | None = None ,
236
237
suppress_small : bool | None = None ,
0 commit comments