MCPcopy Create free account
hub / github.com/numpy/numpy / do_generate_api

Function do_generate_api

numpy/core/code_generators/generate_numpy_api.py:154–225  ·  view source on GitHub ↗
(targets, sources)

Source from the content-addressed store, hash-verified

152 return targets
153
154def do_generate_api(targets, sources):
155 header_file = targets[0]
156 c_file = targets[1]
157
158 global_vars = sources[0]
159 scalar_bool_values = sources[1]
160 types_api = sources[2]
161 multiarray_funcs = sources[3]
162
163 multiarray_api = sources[:]
164
165 module_list = []
166 extension_list = []
167 init_list = []
168
169 # Check multiarray api indexes
170 multiarray_api_index = genapi.merge_api_dicts(multiarray_api)
171 genapi.check_api_dict(multiarray_api_index)
172
173 numpyapi_list = genapi.get_api_functions('NUMPY_API',
174 multiarray_funcs)
175
176 # Create dict name -> *Api instance
177 api_name = 'PyArray_API'
178 multiarray_api_dict = {}
179 for f in numpyapi_list:
180 name = f.name
181 index = multiarray_funcs[name][0]
182 annotations = multiarray_funcs[name][1:]
183 multiarray_api_dict[f.name] = FunctionApi(f.name, index, annotations,
184 f.return_type,
185 f.args, api_name)
186
187 for name, val in global_vars.items():
188 index, type = val
189 multiarray_api_dict[name] = GlobalVarApi(name, index, type, api_name)
190
191 for name, val in scalar_bool_values.items():
192 index = val[0]
193 multiarray_api_dict[name] = BoolValuesApi(name, index, api_name)
194
195 for name, val in types_api.items():
196 index = val[0]
197 internal_type = None if len(val) == 1 else val[1]
198 multiarray_api_dict[name] = TypeApi(
199 name, index, 'PyTypeObject', api_name, internal_type)
200
201 if len(multiarray_api_dict) != len(multiarray_api_index):
202 keys_dict = set(multiarray_api_dict.keys())
203 keys_index = set(multiarray_api_index.keys())
204 raise AssertionError(
205 "Multiarray API size mismatch - "
206 "index has extra keys {}, dict has extra keys {}"
207 .format(keys_index - keys_dict, keys_dict - keys_index)
208 )
209
210 extension_list = []
211 for name, index in genapi.order_dict(multiarray_api_index):

Callers 1

generate_apiFunction · 0.70

Calls 9

FunctionApiClass · 0.90
GlobalVarApiClass · 0.90
BoolValuesApiClass · 0.90
TypeApiClass · 0.90
keysMethod · 0.80
array_api_defineMethod · 0.45
internal_defineMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected