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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
U
O±dáã@sRddlZddlZddlmZmZmZmZddlZdZdZdZ    d dd„Z
d    d
„Z dS) éN)ÚTypeApiÚ GlobalVarApiÚ FunctionApiÚ BoolValuesApia¾
#if defined(_MULTIARRAYMODULE) || defined(WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE)
 
typedef struct {
        PyObject_HEAD
        npy_bool obval;
} PyBoolScalarObject;
 
extern NPY_NO_EXPORT PyTypeObject PyArrayMapIter_Type;
extern NPY_NO_EXPORT PyTypeObject PyArrayNeighborhoodIter_Type;
extern NPY_NO_EXPORT PyBoolScalarObject _PyArrayScalar_BoolValues[2];
 
%s
 
#else
 
#if defined(PY_ARRAY_UNIQUE_SYMBOL)
#define PyArray_API PY_ARRAY_UNIQUE_SYMBOL
#endif
 
#if defined(NO_IMPORT) || defined(NO_IMPORT_ARRAY)
extern void **PyArray_API;
#else
#if defined(PY_ARRAY_UNIQUE_SYMBOL)
void **PyArray_API;
#else
static void **PyArray_API=NULL;
#endif
#endif
 
%s
 
#if !defined(NO_IMPORT_ARRAY) && !defined(NO_IMPORT)
static int
_import_array(void)
{
  int st;
  PyObject *numpy = PyImport_ImportModule("numpy.core._multiarray_umath");
  PyObject *c_api = NULL;
 
  if (numpy == NULL) {
      return -1;
  }
  c_api = PyObject_GetAttrString(numpy, "_ARRAY_API");
  Py_DECREF(numpy);
  if (c_api == NULL) {
      PyErr_SetString(PyExc_AttributeError, "_ARRAY_API not found");
      return -1;
  }
 
  if (!PyCapsule_CheckExact(c_api)) {
      PyErr_SetString(PyExc_RuntimeError, "_ARRAY_API is not PyCapsule object");
      Py_DECREF(c_api);
      return -1;
  }
  PyArray_API = (void **)PyCapsule_GetPointer(c_api, NULL);
  Py_DECREF(c_api);
  if (PyArray_API == NULL) {
      PyErr_SetString(PyExc_RuntimeError, "_ARRAY_API is NULL pointer");
      return -1;
  }
 
  /* Perform runtime check of C API version */
  if (NPY_VERSION != PyArray_GetNDArrayCVersion()) {
      PyErr_Format(PyExc_RuntimeError, "module compiled against "\
             "ABI version 0x%%x but this version of numpy is 0x%%x", \
             (int) NPY_VERSION, (int) PyArray_GetNDArrayCVersion());
      return -1;
  }
  if (NPY_FEATURE_VERSION > PyArray_GetNDArrayCFeatureVersion()) {
      PyErr_Format(PyExc_RuntimeError, "module compiled against "\
             "API version 0x%%x but this version of numpy is 0x%%x . "\
             "Check the section C-API incompatibility at the "\
             "Troubleshooting ImportError section at "\
             "https://numpy.org/devdocs/user/troubleshooting-importerror.html"\
             "#c-api-incompatibility "\
              "for indications on how to solve this problem .", \
             (int) NPY_FEATURE_VERSION, (int) PyArray_GetNDArrayCFeatureVersion());
      return -1;
  }
 
  /*
   * Perform runtime check of endianness and check it matches the one set by
   * the headers (npy_endian.h) as a safeguard
   */
  st = PyArray_GetEndianness();
  if (st == NPY_CPU_UNKNOWN_ENDIAN) {
      PyErr_SetString(PyExc_RuntimeError,
                      "FATAL: module compiled as unknown endian");
      return -1;
  }
#if NPY_BYTE_ORDER == NPY_BIG_ENDIAN
  if (st != NPY_CPU_BIG) {
      PyErr_SetString(PyExc_RuntimeError,
                      "FATAL: module compiled as big endian, but "
                      "detected different endianness at runtime");
      return -1;
  }
#elif NPY_BYTE_ORDER == NPY_LITTLE_ENDIAN
  if (st != NPY_CPU_LITTLE) {
      PyErr_SetString(PyExc_RuntimeError,
                      "FATAL: module compiled as little endian, but "
                      "detected different endianness at runtime");
      return -1;
  }
#endif
 
  return 0;
}
 
#define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NULL; } }
 
#define import_array1(ret) {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return ret; } }
 
#define import_array2(msg, ret) {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, msg); return ret; } }
 
#endif
 
#endif
z{
/* These pointers will be stored in the C-object for use in other
    extension modules
*/
 
void *PyArray_API[] = {
%s
};
z%
===========
NumPy C-API
===========
FcCsrd}tj |d|¡}tj |d|¡}tj |d|¡}|||f}tj}|sdt |tjtg¡sd|St||ƒ|S)NÚmultiarray_apiz__%s.hz__%s.cz%s.txt)    ÚosÚpathÚjoinÚ    numpy_apirÚgenapiZshould_rebuildÚ__file__Údo_generate_api)Ú
output_dirÚforceÚbasenameZh_fileÚc_fileZd_fileÚtargetsÚsources©rúTd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/core/generate_numpy_api.pyÚ generate_api”s
 
rcCsb|d}|d}|d}|d}|d}|d}|d}|dd…}    g}
g} g} t |    ¡} t | ¡t d|¡}d}i}|D]D}|j}||d}||dd…}t|j|||j|j|ƒ||j<q|| ¡D]"\}}|\}}t    ||||ƒ||<qÊ| ¡D] \}}|d}t
|||ƒ||<qö| ¡D]@\}}|d}t |ƒdkrBdn|d}t ||d||ƒ||<q t |ƒt | ƒkr¤t | ¡ƒ}t |  ¡ƒ}td ||||¡ƒ‚g} t | ¡D]<\}}||}|  | ¡¡|  | ¡¡|
 | ¡¡q²td     |
¡d     | ¡f}t ||¡td
 | ¡}t ||¡t}|D]}|| ¡7}|d 7}q6t ||¡|S) NréééZ    NUMPY_APIZ PyArray_APIZ PyTypeObjectzNMultiarray API size mismatch - index has extra keys {}, dict has extra keys {}Ú
z,
z
 
)r Zmerge_api_dictsZcheck_api_dictZget_api_functionsÚnamerÚ return_typeÚargsÚitemsrrÚlenrÚsetÚkeysÚAssertionErrorÚformatZ
order_dictÚappendZdefine_from_array_api_stringZarray_api_defineZinternal_defineÚ
h_templater    Ú
write_fileÚ
c_templateÚ c_api_headerZto_ReST)rrZ header_filerZdoc_fileÚ global_varsZscalar_bool_valuesZ    types_apiZmultiarray_funcsrZ module_listZextension_listZ    init_listZmultiarray_api_indexZ numpyapi_listZapi_nameZmultiarray_api_dictÚfrÚindexÚ annotationsÚvalÚtypeZ internal_typeZ    keys_dictZ
keys_indexZapi_itemÚsÚfuncrrrr ¥sˆ 
 
ÿ 
þ ÿ   þÿ     r )F) rr rrrrr
r%r'r(rr rrrrÚ<module>sz