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

Function array_frombuffer

numpy/core/src/multiarray/multiarraymodule.c:2499–2528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2497}
2498
2499static PyObject *
2500array_frombuffer(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *keywds)
2501{
2502 PyObject *obj = NULL;
2503 Py_ssize_t nin = -1, offset = 0;
2504 static char *kwlist[] = {"buffer", "dtype", "count", "offset", "like", NULL};
2505 PyObject *like = Py_None;
2506 PyArray_Descr *type = NULL;
2507
2508 if (!PyArg_ParseTupleAndKeywords(args, keywds,
2509 "O|O&" NPY_SSIZE_T_PYFMT NPY_SSIZE_T_PYFMT "$O:frombuffer", kwlist,
2510 &obj, PyArray_DescrConverter, &type, &nin, &offset, &like)) {
2511 Py_XDECREF(type);
2512 return NULL;
2513 }
2514
2515 if (like != Py_None) {
2516 PyObject *deferred = array_implement_c_array_function_creation(
2517 "frombuffer", like, args, keywds, NULL, 0, NULL);
2518 if (deferred != Py_NotImplemented) {
2519 Py_XDECREF(type);
2520 return deferred;
2521 }
2522 }
2523
2524 if (type == NULL) {
2525 type = PyArray_DescrFromType(NPY_DEFAULT_TYPE);
2526 }
2527 return PyArray_FromBuffer(obj, type, (npy_intp)nin, (npy_intp)offset);
2528}
2529
2530static PyObject *
2531array_concatenate(PyObject *NPY_UNUSED(dummy),

Callers

nothing calls this directly

Tested by

no test coverage detected