@@ -150,16 +150,56 @@ def make_or(x, y):
150150]
151151
152152# workaround changes in numpy interaction with getfullargspec
153- try :
154- inspect .getfullargspec (numpy .asarray )
155- # if we have a description, honor it
156- extra_numpy_asarray_descr = {}
157- except TypeError :
158- extra_numpy_asarray_descr = {'args' :('a' , 'dtype' ),
159- 'defaults' : (None ,)}
160-
153+ _extra_descr = {
154+ "asarray" : {
155+ 'args' :('a' , 'dtype' ),
156+ 'defaults' : (None ,)
157+ },
158+ "array" : {
159+ 'args' : ('object' , 'dtype' ),
160+ 'defaults' : (None ,),
161+ },
162+ "arange" : {
163+ 'args' :('start' , 'stop' , 'step' , 'dtype' ),
164+ 'defaults' :(1 , None ),
165+ },
166+ "concatenate" : {
167+ 'args' : ('_' , 'axis' ),
168+ 'defaults' : (0 ,),
169+ },
170+ "empty" : {
171+ 'args' : ('shape' , 'dtype' ),
172+ 'defaults' : ("numpy.float64" ,),
173+ },
174+ "empty_like" : {
175+ 'args' : ('a' , 'dtype' ),
176+ 'defaults' : ("numpy.float64" ,),
177+ },
178+ "fromiter" : {
179+ 'args' : ("iterable" , "dtype" , "count" ),
180+ 'defaults' : (- 1 ,),
181+ },
182+ "fromfile" : {
183+ 'args' : ('file' , 'dtype' , 'count' , "sep" , "offset" ),
184+ 'defaults' : (None , None , - 1 , None , 0 ),
185+ },
186+ "zeros" : {
187+ 'args' : ('shape' , 'dtype' ),
188+ 'defaults' : ("numpy.float64" ,),
189+ },
190+ }
161191
162192
193+ for attr in list (_extra_descr .keys ()):
194+ try :
195+ obj = getattr (numpy , attr )
196+ while hasattr (obj , '__wrapped__' ):
197+ obj = obj .__wrapped__
198+ inspect .getfullargspec (obj )
199+ # if we have a description, honor it
200+ _extra_descr [attr ].clear ()
201+ except (TypeError , AttributeError ):
202+ ...
163203
164204
165205def update_effects (self , node ):
@@ -3167,8 +3207,7 @@ def expand_numpy_2_args(args, defaults=None, force=False):
31673207 NDArray [complex , :]],
31683208 ],
31693209 return_range_content = interval .range_values ,
3170- args = ('start' , 'stop' , 'step' , 'dtype' ),
3171- defaults = (1 , None )
3210+ ** _extra_descr ["arange" ]
31723211 ),
31733212 "arccos" : ConstFunctionIntr (signature = _numpy_unary_op_float_signature ),
31743213 "arccosh" : ConstFunctionIntr (
@@ -3201,8 +3240,7 @@ def expand_numpy_2_args(args, defaults=None, force=False):
32013240 ),
32023241 "around" : ConstFunctionIntr (signature = _numpy_around_signature ),
32033242 "array" : FunctionIntr (signature = _numpy_array_signature ,
3204- args = ('object' , 'dtype' ),
3205- defaults = (None ,)),
3243+ ** _extra_descr ["array" ]),
32063244 "array2string" : ConstFunctionIntr (
32073245 signature = _numpy_array_str_signature ),
32083246 "array_equal" : ConstFunctionIntr (signature = Fun [[T0 , T1 ], bool ]),
@@ -3217,7 +3255,7 @@ def expand_numpy_2_args(args, defaults=None, force=False):
32173255 ),
32183256 "array_str" : ConstFunctionIntr (signature = _numpy_array_str_signature ),
32193257 "asarray" : ReadOnceFunctionIntr (signature = _numpy_array_signature ,
3220- ** extra_numpy_asarray_descr ),
3258+ ** _extra_descr [ 'asarray' ] ),
32213259 "asarray_chkfinite" : ConstFunctionIntr (
32223260 signature = _numpy_array_signature ),
32233261 "ascontiguousarray" : ConstFunctionIntr (
@@ -3411,8 +3449,6 @@ def expand_numpy_2_args(args, defaults=None, force=False):
34113449 "ceil" : ConstFunctionIntr (signature = _numpy_float_unary_op_signature ),
34123450 "clip" : ConstMethodIntr (signature = _numpy_ternary_op_signature ),
34133451 "concatenate" : ConstFunctionIntr (
3414- args = ('_' , 'axis' ),
3415- defaults = (0 ,),
34163452 signature = Union [
34173453 # 1D
34183454 Fun [[Iterable [Iterable [bool ]]], NDArray [bool , :]],
@@ -3578,7 +3614,8 @@ def expand_numpy_2_args(args, defaults=None, force=False):
35783614 Iterable [Iterable [complex ]],
35793615 Iterable [Iterable [complex ]], int ]],
35803616 NDArray [complex , :, :]],
3581- ]
3617+ ],
3618+ ** _extra_descr ["concatenate" ]
35823619 ),
35833620 "complex64" : ConstFunctionIntr (signature = _complex_signature ),
35843621 "complex128" : ConstFunctionIntr (signature = _complex_signature ),
@@ -3713,15 +3750,14 @@ def expand_numpy_2_args(args, defaults=None, force=False):
37133750 "dtype" : ClassWithConstConstructor (CLASSES ["dtype" ]),
37143751 "e" : ConstantIntr (),
37153752 "ediff1d" : ConstFunctionIntr (),
3716- "empty" : ConstFunctionIntr (args = ('shape' , 'dtype' ),
3717- defaults = ("numpy.float64" ,),
3753+ "empty" : ConstFunctionIntr (
37183754 signature = _numpy_ones_signature ,
37193755 global_effects = True , # to avoid folding
3756+ ** _extra_descr ["empty" ]
37203757 ),
37213758 "empty_like" : ConstFunctionIntr (
3722- args = ('a' , 'dtype' ),
3723- defaults = ("numpy.float64" ,),
3724- signature = _numpy_ones_like_signature
3759+ signature = _numpy_ones_like_signature ,
3760+ ** _extra_descr ["empty_like" ]
37253761 ),
37263762 "equal" : UFunc (BINARY_UFUNC ),
37273763 "exp" : ConstFunctionIntr (signature = _numpy_unary_op_float_signature ),
@@ -3755,14 +3791,12 @@ def expand_numpy_2_args(args, defaults=None, force=False):
37553791 "frexp" : ConstFunctionIntr (),
37563792 "frombuffer" : ConstFunctionIntr (),
37573793 "fromfunction" : ConstFunctionIntr (),
3758- "fromiter" : ConstFunctionIntr (args = ("iterable" , "dtype" , "count" ),
3759- defaults = (- 1 ,)),
3794+ "fromiter" : ConstFunctionIntr (** _extra_descr ["fromiter" ]),
37603795 "fromstring" : ConstFunctionIntr (args = ('string' , 'dtype' , 'count' ,),
37613796 kwonlyargs = ('sep' , 'like' ),
37623797 defaults = (float , - 1 , '' , None )),
3763- "fromfile" : FunctionIntr (args = ('file' , 'dtype' , 'count' , "sep" , "offset" ),
3764- defaults = (None , None , - 1 , None , 0 ),
3765- global_effects = True ),
3798+ "fromfile" : FunctionIntr (global_effects = True ,
3799+ ** _extra_descr ["fromfile" ]),
37663800 "full" : ConstFunctionIntr (signature = _numpy_ones_signature ),
37673801 "full_like" : ConstFunctionIntr (signature = _numpy_ones_like_signature ),
37683802 "greater" : UFunc (
@@ -4079,10 +4113,8 @@ def expand_numpy_2_args(args, defaults=None, force=False):
40794113 "vdot" : ConstMethodIntr (requires_blas = True ),
40804114 "vstack" : ConstFunctionIntr (),
40814115 "where" : ConstFunctionIntr (),
4082- "zeros" : ConstFunctionIntr (args = ('shape' , 'dtype' ),
4083- defaults = ("numpy.float64" ,),
4084- signature = _numpy_ones_signature ,
4085- ),
4116+ "zeros" : ConstFunctionIntr (signature = _numpy_ones_signature ,
4117+ ** _extra_descr ["zeros" ]),
40864118 "zeros_like" : ConstFunctionIntr (signature = _numpy_ones_like_signature ),
40874119 },
40884120 "time" : {
@@ -4546,6 +4578,9 @@ def expand_numpy_2_args(args, defaults=None, force=False):
45464578 },
45474579}
45484580
4581+ # numpy alias
4582+ MODULES ['numpy' ]['concat' ] = MODULES ['numpy' ]['concatenate' ]
4583+
45494584# PyPy doesn't seem to provide this.
45504585if sys .implementation .name == 'pypy' :
45514586 del MODULES ['array' ]['typecodes' ]
@@ -4562,9 +4597,6 @@ def expand_numpy_2_args(args, defaults=None, force=False):
45624597if 'WindowsError' in sys .modules ['builtins' ].__dict__ :
45634598 MODULES ['builtins' ]['WindowsError' ] = ConstExceptionIntr ()
45644599
4565- # numpy alias
4566- MODULES ['numpy' ]['concat' ] = MODULES ['numpy' ]['concatenate' ]
4567-
45684600# detect and prune unsupported modules
45694601for module_name in ["omp" , "scipy" , "scipy.special" ]:
45704602 try :
0 commit comments