@@ -6,7 +6,7 @@ import decimal
6
6
import fractions
7
7
from collections .abc import Sequence
8
8
from typing import Any , TypeAlias , type_check_only
9
- from typing_extensions import Protocol , TypeAliasType , TypeVar , Unpack
9
+ from typing_extensions import Never , Protocol , TypeAliasType , TypeVar , Unpack
10
10
11
11
import numpy as np
12
12
from numpy ._typing import _NestedSequence
@@ -97,17 +97,14 @@ from ._scalar_co import (
97
97
# Type parameters
98
98
99
99
_T = TypeVar ("_T" )
100
+ _ShapeT = TypeVar ("_ShapeT" , bound = tuple [int , ...], default = tuple [int , ...])
100
101
_ShapeT_co = TypeVar ("_ShapeT_co" , bound = tuple [int , ...], covariant = True )
101
102
_ScalarT = TypeVar ("_ScalarT" , bound = np .generic )
102
103
_ScalarT_co = TypeVar ("_ScalarT_co" , bound = np .generic , covariant = True )
103
104
_ScalarT0 = TypeVar ("_ScalarT0" , bound = np .generic , default = Any )
105
+ _NaObjectT = TypeVar ("_NaObjectT" , default = Never )
104
106
_ToT = TypeVar ("_ToT" )
105
107
106
- ###
107
- # Type constraints (bijective type mappings)
108
-
109
- _ShapeT = TypeVar ("_ShapeT" , bound = tuple [int , ...], default = tuple [int , ...])
110
-
111
108
###
112
109
# Protocols
113
110
@@ -185,6 +182,37 @@ MArray3D = TypeAliasType("MArray3D", np.ma.MaskedArray[tuple[int, int, int], np.
185
182
186
183
Matrix = TypeAliasType ("Matrix" , np .matrix [tuple [int , int ], np .dtype [_ScalarT0 ]], type_params = (_ScalarT0 ,))
187
184
185
+ StringArray = TypeAliasType (
186
+ "StringArray" ,
187
+ np .ndarray [_ShapeT , np .dtypes .StringDType [_NaObjectT ]],
188
+ type_params = (_ShapeT , _NaObjectT ),
189
+ )
190
+ StringArray0D = TypeAliasType (
191
+ "StringArray0D" ,
192
+ np .ndarray [tuple [()], np .dtypes .StringDType [_NaObjectT ]],
193
+ type_params = (_NaObjectT ,),
194
+ )
195
+ StringArray1D = TypeAliasType (
196
+ "StringArray1D" ,
197
+ np .ndarray [tuple [int ], np .dtypes .StringDType [_NaObjectT ]],
198
+ type_params = (_NaObjectT ,),
199
+ )
200
+ StringArray2D = TypeAliasType (
201
+ "StringArray2D" ,
202
+ np .ndarray [tuple [int , int ], np .dtypes .StringDType [_NaObjectT ]],
203
+ type_params = (_NaObjectT ,),
204
+ )
205
+ StringArray3D = TypeAliasType (
206
+ "StringArray3D" ,
207
+ np .ndarray [tuple [int , int , int ], np .dtypes .StringDType [_NaObjectT ]],
208
+ type_params = (_NaObjectT ,),
209
+ )
210
+ StringArrayND = TypeAliasType (
211
+ "StringArrayND" ,
212
+ np .ndarray [tuple [int , ...], np .dtypes .StringDType [_NaObjectT ]],
213
+ type_params = (_NaObjectT ,),
214
+ )
215
+
188
216
###
189
217
# helper aliases
190
218
0 commit comments