U C^Y@sdZddlmZmZmZddlZddgZddZdd Zd d Z d \Z Z Z Z d dZddZddZddZefddZdddeddddddefddZeddddddefddZdS) zSubset of inspect module from upstream python We use this instead of upstream because upstream inspect is slow to import, and significantly contributes to numpy import times. Importing this copy has almost no overhead. )divisionabsolute_importprint_functionN getargspec formatargspeccCs t|tjS)aReturn true if the object is an instance method. Instance method objects provide these attributes: __doc__ documentation string __name__ name with which this method was defined im_class class object in which this method belongs im_func function object containing implementation of method im_self instance to which this method is bound, or None ) isinstancetypes MethodTypeobjectr 8/tmp/pip-install-6_kvzl1k/numpy/numpy/compat/_inspect.pyismethods rcCs t|tjS)aReturn true if the object is a user-defined function. Function objects provide these attributes: __doc__ documentation string __name__ name with which this function was defined func_code code object containing compiled function bytecode func_defaults tuple of any default values for arguments func_doc (same as __doc__) func_globals global namespace in which this function was defined func_name (same as __name__) )rr FunctionTyper r r r isfunctions rcCs t|tjS)aReturn true if the object is a code object. Code objects provide these attributes: co_argcount number of arguments (not including * or ** args) co_code string of raw compiled bytecode co_consts tuple of constants used in the bytecode co_filename name of file in which this code object was created co_firstlineno number of first line in Python source code co_flags bitmap: 1=optimized | 2=newlocals | 4=*arg | 8=**arg co_lnotab encoded mapping of line numbers to bytecode indices co_name name with which this code object was defined co_names tuple of names of local variables co_nlocals number of local variables co_stacksize virtual machine stack space required co_varnames tuple of names of arguments and local variables )rrCodeTyper r r r iscode+sr)cCst|std|j}|j}t|d|}t|D] }||dddkr4tdq4d}|jt@rv|j|}|d}d}|jt@r|j|}|||fS)aGet information about the arguments accepted by a code object. Three things are returned: (args, varargs, varkw), where 'args' is a list of argument names (possibly containing nested lists), and 'varargs' and 'varkw' are the names of the * and ** arguments or None. zarg is not a code objectNr).z*tuple function arguments are not supported) r TypeError co_argcount co_varnameslistrangeco_flags CO_VARARGSCO_VARKEYWORDS)conargsnamesargsivarargsvarkwr r r getargsCs       r(cCs<t|r|j}t|stdt|j\}}}||||jfS)amGet the names and default values of a function's arguments. A tuple of four things is returned: (args, varargs, varkw, defaults). 'args' is a list of the argument names (it may contain nested lists). 'varargs' and 'varkw' are the names of the * and ** arguments or None. 'defaults' is an n-tuple of the default values of the last n arguments. zarg is not a Python function)r__func__rrr(__code__ __defaults__)funcr$r&r'r r r rbs cCst|j\}}}||||jfS)aaGet information about arguments passed into a particular frame. A tuple of four things is returned: (args, varargs, varkw, locals). 'args' is a list of the argument names (it may contain nested lists). 'varargs' and 'varkw' are the names of the * and ** arguments or None. 'locals' is the locals dictionary of the given frame. )r(f_codef_locals)framer$r&r'r r r getargvaluesss r0cCs2t|dkrd|ddSdd|dSdS)Nr(rz,), ))lenjoin)seqr r r joinseqs r7cs4t|ttfkr(fdd|DS|SdS)z=Recursively walk a sequence, stringifying each element. csg|]}t|qSr strseq).0Z_oconvertr5r r szstrseq..N)typertuple)r r<r5r r;r r9sr9cCsd|SN*r namer r r rDcCsd|SNz**r rBr r r rDrEcCs dt|SN=reprvaluer r r rDrEc Csg} |rt|t|} tt|D]>} t|| ||} |rX| | krX| ||| | } | | q$|dk rz| |||dk r| ||dd| dS)amFormat an argument spec from the 4 values returned by getargspec. The first four arguments are (args, varargs, varkw, defaults). The other four arguments are the corresponding optional formatting functions that are called to turn names and values into strings. The ninth argument is an optional function to format the sequence of arguments. Nr1r2r3)r4rr9appendr5) r$r&r'defaults formatarg formatvarargs formatvarkw formatvaluer5specs firstdefaultr%specr r r rs  cCsd|Sr@r rBr r r rDrEcCsd|SrFr rBr r r rDrEcCs dt|SrGrIrKr r r rDrEc sr|||fddfdd|D} |rB| ||||||r`| |||||dd| dS)alFormat an argument spec from the 4 values returned by getargvalues. The first four arguments are (args, varargs, varkw, locals). The next four arguments are the corresponding optional formatting functions that are called to turn names and values into strings. The ninth argument is an optional function to format the sequence of arguments. cSs|||||S)Nr )rClocalsrOrRr r r r<sz formatargvalues..convertcsg|]}t|qSr r8)r:argr;r r r=sz#formatargvalues..r1r2r3)rMr5) r$r&r'rVrOrPrQrRr5rSr r;r formatargvaluess rX)__doc__ __future__rrrr__all__rrrZ CO_OPTIMIZEDZ CO_NEWLOCALSrr r(rr0r7r9strrrXr r r r s2