1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
U
O±dÖã@s®dZddlZddgZdd„Zdd„Zd    d
„Zd \ZZZZ    d d „Z
dd„Z dd„Z dd„Z e fdd„Zdddedd„dd„dd„e fdd„Zedd„dd„dd„e fdd„ZdS)zÝSubset 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.
 
éNÚ
getargspecÚ formatargspeccCs t|tjƒS)a°Return 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
 
    )Ú
isinstanceÚtypesÚ
MethodType©Úobject©r    úLd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/compat/_inspect.pyÚismethod s r cCs t|tjƒS)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Ú FunctionTyperr    r    r
Ú
isfunctions r cCs t|tjƒS)aƒReturn 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
        
    )rrÚCodeTyperr    r    r
Úiscode)sr)éééécCs˜t|ƒstdƒ‚|j}|j}t|d|…ƒ}t|ƒD] }||dd…dkr4tdƒ‚q4d}|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_varnamesÚlistÚrangeÚco_flagsÚ
CO_VARARGSÚCO_VARKEYWORDS)ÚcoÚnargsÚnamesÚargsÚiÚvarargsÚvarkwr    r    r
ÚgetargsAs      
 
 
 
 
r%cCs<t|ƒr|j}t|ƒstdƒ‚t|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__r rr%Ú__code__Ú __defaults__)Úfuncr!r#r$r    r    r
r`s
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_codeÚf_locals)Úframer!r#r$r    r    r
Ú getargvaluesqs    r-cCs2t|ƒdkrd|ddSdd |¡dSdS)Nrú(rz,)ú, ú))ÚlenÚjoin)Úseqr    r    r
Újoinseq}s r4cs4t|ƒttfkr(ˆ‡‡fdd„|DƒƒSˆ|ƒSdS)z=Recursively walk a sequence, stringifying each element.
 
    csg|]}t|ˆˆƒ‘qSr    ©Ústrseq)Ú.0Z_o©Úconvertr2r    r
Ú
<listcomp>ˆszstrseq.<locals>.<listcomp>N)ÚtyperÚtuple)rr9r2r    r8r
r6ƒsr6cCsd|S©NÚ*r    ©Únamer    r    r
Ú<lambda>ŽórAcCsd|S©Nz**r    r?r    r    r
rArBcCs dt|ƒS©Nú=©Úrepr©Úvaluer    r    r
rArBc     Cs¢g}    |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.
 
    Nr.r/r0)r1rr6Úappendr2) r!r#r$ÚdefaultsÚ    formatargÚ formatvarargsÚ formatvarkwÚ formatvaluer2ÚspecsÚ firstdefaultr"Úspecr    r    r
rŒs  cCsd|Sr=r    r?r    r    r
rAªrBcCsd|SrCr    r?r    r    r
rA«rBcCs dt|ƒSrDrFrHr    r    r
rA¬rBc    
sr|||fdd„‰‡‡fdd„|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    )r@ÚlocalsrLrOr    r    r
r9¶sz formatargvalues.<locals>.convertcsg|]}t|ˆˆƒ‘qSr    r5)r7Úargr8r    r
r:¹sz#formatargvalues.<locals>.<listcomp>r.r/r0)rJr2)
r!r#r$rSrLrMrNrOr2rPr    r8r
Úformatargvalues¨sÿ
rU)Ú__doc__rÚ__all__r r rZ CO_OPTIMIZEDZ CO_NEWLOCALSrrr%rr-r4r6ÚstrrrUr    r    r    r
Ú<module>s0        û
û