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

Function copy_positional_args_to_kwargs

numpy/core/src/umath/override.c:171–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169
170
171static int
172copy_positional_args_to_kwargs(const char **keywords,
173 PyObject *const *args, Py_ssize_t len_args,
174 PyObject *normal_kwds)
175{
176 for (Py_ssize_t i = 0; i < len_args; i++) {
177 if (keywords[i] == NULL) {
178 /* keyword argument is either input or output and not set here */
179 continue;
180 }
181 if (NPY_UNLIKELY(i == 5)) {
182 /*
183 * This is only relevant for reduce, which is the only one with
184 * 5 keyword arguments.
185 */
186 static PyObject *NoValue = NULL;
187 assert(strcmp(keywords[i], "initial") == 0);
188 npy_cache_import("numpy", "_NoValue", &NoValue);
189 if (args[i] == NoValue) {
190 continue;
191 }
192 }
193
194 int res = PyDict_SetItemString(normal_kwds, keywords[i], args[i]);
195 if (res < 0) {
196 return -1;
197 }
198 }
199 return 0;
200}
201
202/*
203 * Check a set of args for the `__array_ufunc__` method. If more than one of

Callers 1

PyUFunc_CheckOverrideFunction · 0.85

Calls 1

npy_cache_importFunction · 0.85

Tested by

no test coverage detected