1- from typing import assert_type
1+ from typing import Any , TypeAlias , assert_type
22from typing_extensions import TypeVar
33
44import _numtype as _nt
55import numpy as np
66
77_ScalarT = TypeVar ("_ScalarT" , bound = np .generic )
88
9+ _Histogram2D : TypeAlias = tuple [_nt .Array2D [np .float64 ], _nt .Array1D [_ScalarT ], _nt .Array1D [_ScalarT ]]
10+
911def func1 (ar : _nt .Array [_ScalarT ], a : int ) -> _nt .Array [_ScalarT ]: ...
1012def func2 (ar : _nt .Array [np .number ], a : str ) -> _nt .Array [np .float64 ]: ...
1113
@@ -19,6 +21,8 @@ AR_O: _nt.Array[np.object_]
1921AR_LIKE_b : list [bool ]
2022AR_LIKE_c : list [complex ]
2123
24+ ###
25+
2226assert_type (np .fliplr (AR_b ), _nt .Array [np .bool ])
2327assert_type (np .fliplr (AR_LIKE_b ), _nt .Array )
2428
@@ -30,63 +34,43 @@ assert_type(np.eye(10, M=20, dtype=np.int64), _nt.Array[np.int64])
3034assert_type (np .eye (10 , k = 2 , dtype = int ), _nt .Array )
3135
3236assert_type (np .diag (AR_b ), _nt .Array [np .bool ])
33- assert_type (np .diag (AR_LIKE_b , k = 0 ), _nt .Array )
37+ assert_type (np .diag (AR_LIKE_b , k = 0 ), _nt .Array2D )
3438
35- assert_type (np .diagflat (AR_b ), _nt .Array [np .bool ])
36- assert_type (np .diagflat (AR_LIKE_b , k = 0 ), _nt .Array )
39+ assert_type (np .diagflat (AR_b ), _nt .Array2D [np .bool ])
40+ assert_type (np .diagflat (AR_LIKE_b , k = 0 ), _nt .Array2D )
3741
38- assert_type (np .tri (10 ), _nt .Array [np .float64 ])
39- assert_type (np .tri (10 , M = 20 , dtype = np .int64 ), _nt .Array [np .int64 ])
40- assert_type (np .tri (10 , k = 2 , dtype = int ), _nt .Array )
42+ assert_type (np .tri (10 ), _nt .Array2D [np .float64 ])
43+ assert_type (np .tri (10 , M = 20 , dtype = np .int64 ), _nt .Array2D [np .int64 ])
44+ assert_type (np .tri (10 , k = 2 , dtype = int ), _nt .Array2D )
4145
4246assert_type (np .tril (AR_b ), _nt .Array [np .bool ])
4347assert_type (np .tril (AR_LIKE_b , k = 0 ), _nt .Array [np .bool ])
4448
4549assert_type (np .triu (AR_b ), _nt .Array [np .bool ])
4650assert_type (np .triu (AR_LIKE_b , k = 0 ), _nt .Array [np .bool ])
4751
48- assert_type (np .vander (AR_b ), _nt .Array [np .intp ])
49- assert_type (np .vander (AR_u ), _nt .Array [np .signedinteger ])
50- assert_type (np .vander (AR_i , N = 2 ), _nt .Array [np .signedinteger ])
51- assert_type (np .vander (AR_f , increasing = True ), _nt .Array [np .floating ])
52- assert_type (np .vander (AR_c ), _nt .Array [np .complexfloating ])
53- assert_type (np .vander (AR_O ), _nt .Array [np .object_ ])
54-
55- assert_type (
56- np .histogram2d (AR_LIKE_c , AR_LIKE_c ),
57- tuple [_nt .Array [np .float64 ], _nt .Array [np .complex128 | np .float64 ], _nt .Array [np .complex128 | np .float64 ]],
58- )
59- assert_type (np .histogram2d (AR_i , AR_b ), tuple [_nt .Array [np .float64 ], _nt .Array [np .float64 ], _nt .Array [np .float64 ]])
60- assert_type (np .histogram2d (AR_f , AR_i ), tuple [_nt .Array [np .float64 ], _nt .Array [np .float64 ], _nt .Array [np .float64 ]])
61- assert_type (np .histogram2d (AR_i , AR_f ), tuple [_nt .Array [np .float64 ], _nt .Array [np .float64 ], _nt .Array [np .float64 ]])
62- assert_type (
63- np .histogram2d (AR_f , AR_c , weights = AR_LIKE_b ),
64- tuple [_nt .Array [np .float64 ], _nt .Array [np .complex128 ], _nt .Array [np .complex128 ]],
65- )
66- assert_type (
67- np .histogram2d (AR_f , AR_c , bins = 8 ), tuple [_nt .Array [np .float64 ], _nt .Array [np .complex128 ], _nt .Array [np .complex128 ]]
68- )
69- assert_type (
70- np .histogram2d (AR_c , AR_f , bins = (8 , 5 )),
71- tuple [_nt .Array [np .float64 ], _nt .Array [np .complex128 ], _nt .Array [np .complex128 ]],
72- )
73- assert_type (
74- np .histogram2d (AR_c , AR_i , bins = AR_u ), tuple [_nt .Array [np .float64 ], _nt .Array [np .uint64 ], _nt .Array [np .uint64 ]]
75- )
76- assert_type (
77- np .histogram2d (AR_c , AR_c , bins = (AR_u , AR_u )),
78- tuple [_nt .Array [np .float64 ], _nt .Array [np .uint64 ], _nt .Array [np .uint64 ]],
79- )
80- assert_type (
81- np .histogram2d (AR_c , AR_c , bins = (AR_b , 8 )),
82- tuple [_nt .Array [np .float64 ], _nt .Array [np .bool | np .complex128 ], _nt .Array [np .bool | np .complex128 ]],
83- )
84-
85- assert_type (np .mask_indices (10 , func1 ), tuple [_nt .Array [np .intp ], _nt .Array [np .intp ]])
86- assert_type (np .mask_indices (8 , func2 , "0" ), tuple [_nt .Array [np .intp ], _nt .Array [np .intp ]])
87-
88- assert_type (np .tril_indices (10 ), tuple [_nt .Array [np .intp ], _nt .Array [np .intp ]])
89- assert_type (np .triu_indices (10 ), tuple [_nt .Array [np .intp ], _nt .Array [np .intp ]])
90-
91- assert_type (np .tril_indices_from (AR_b ), tuple [_nt .Array [np .intp ], _nt .Array [np .intp ]])
92- assert_type (np .triu_indices_from (AR_b ), tuple [_nt .Array [np .intp ], _nt .Array [np .intp ]])
52+ assert_type (np .vander (AR_b ), _nt .Array2D [np .intp ])
53+ assert_type (np .vander (AR_u ), _nt .Array2D [np .int_ ])
54+ assert_type (np .vander (AR_i , N = 2 ), _nt .Array2D [np .int_ ])
55+ assert_type (np .vander (AR_f , increasing = True ), _nt .Array2D [np .float64 ])
56+ assert_type (np .vander (AR_c ), _nt .Array2D [np .complex128 ])
57+ assert_type (np .vander (AR_O ), _nt .Array2D [np .object_ ])
58+
59+ assert_type (np .histogram2d (AR_LIKE_c , AR_LIKE_c ), _Histogram2D [np .complex128 | Any ])
60+ assert_type (np .histogram2d (AR_f , AR_i ), _Histogram2D [np .float64 ])
61+ assert_type (np .histogram2d (AR_i , AR_f ), _Histogram2D [np .float64 ])
62+ assert_type (np .histogram2d (AR_f , AR_c , weights = AR_LIKE_b ), _Histogram2D [np .complex128 ])
63+ assert_type (np .histogram2d (AR_f , AR_c , bins = 8 ), _Histogram2D [np .complex128 ])
64+ assert_type (np .histogram2d (AR_c , AR_f , bins = (8 , 5 )), _Histogram2D [np .complex128 ])
65+ assert_type (np .histogram2d (AR_c , AR_i , bins = AR_u ), _Histogram2D [np .uint64 ])
66+ assert_type (np .histogram2d (AR_c , AR_c , bins = (AR_u , AR_u )), _Histogram2D [np .uint64 ])
67+ assert_type (np .histogram2d (AR_c , AR_c , bins = (AR_b , 8 )), _Histogram2D [np .bool | np .complex128 ])
68+
69+ assert_type (np .mask_indices (10 , func1 ), tuple [_nt .Array1D [np .intp ], _nt .Array1D [np .intp ]])
70+ assert_type (np .mask_indices (8 , func2 , "0" ), tuple [_nt .Array1D [np .intp ], _nt .Array1D [np .intp ]])
71+
72+ assert_type (np .tril_indices (10 ), tuple [_nt .Array1D [np .intp ], _nt .Array1D [np .intp ]])
73+ assert_type (np .triu_indices (10 ), tuple [_nt .Array1D [np .intp ], _nt .Array1D [np .intp ]])
74+
75+ assert_type (np .tril_indices_from (AR_b ), tuple [_nt .Array1D [np .intp ], _nt .Array1D [np .intp ]])
76+ assert_type (np .triu_indices_from (AR_b ), tuple [_nt .Array1D [np .intp ], _nt .Array1D [np .intp ]])
0 commit comments