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

Function PyArray_CopyConverter

numpy/core/src/multiarray/conversion_utils.c:227–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227NPY_NO_EXPORT int
228PyArray_CopyConverter(PyObject *obj, _PyArray_CopyMode *copymode) {
229 if (obj == Py_None) {
230 PyErr_SetString(PyExc_ValueError,
231 "NoneType copy mode not allowed.");
232 return NPY_FAIL;
233 }
234
235 int int_copymode;
236 static PyObject* numpy_CopyMode = NULL;
237 npy_cache_import("numpy", "_CopyMode", &numpy_CopyMode);
238
239 if (numpy_CopyMode != NULL && (PyObject *)Py_TYPE(obj) == numpy_CopyMode) {
240 PyObject* mode_value = PyObject_GetAttrString(obj, "value");
241 if (mode_value == NULL) {
242 return NPY_FAIL;
243 }
244
245 int_copymode = (int)PyLong_AsLong(mode_value);
246 Py_DECREF(mode_value);
247 if (error_converting(int_copymode)) {
248 return NPY_FAIL;
249 }
250 }
251 else {
252 npy_bool bool_copymode;
253 if (!PyArray_BoolConverter(obj, &bool_copymode)) {
254 return NPY_FAIL;
255 }
256 int_copymode = (int)bool_copymode;
257 }
258
259 *copymode = (_PyArray_CopyMode)int_copymode;
260 return NPY_SUCCEED;
261}
262
263/*NUMPY_API
264 * Get buffer chunk from object

Callers

nothing calls this directly

Calls 2

npy_cache_importFunction · 0.85
PyArray_BoolConverterFunction · 0.85

Tested by

no test coverage detected