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

Function _convert_from_commastring

numpy/core/src/multiarray/descriptor.c:724–754  ·  view source on GitHub ↗

* comma-separated string * this is the format developed by the numarray records module and implemented * by the format parser in that module this is an alternative implementation * found in the _internal.py file patterned after that one -- the approach is * to try to convert to a list (with tuples if any repeat information is * present) and then call the _convert_from_list) * * TODO: Callin

Source from the content-addressed store, hash-verified

722 * a good idea. This should all be converted to C code.
723 */
724static PyArray_Descr *
725_convert_from_commastring(PyObject *obj, int align)
726{
727 PyObject *listobj;
728 PyArray_Descr *res;
729 PyObject *_numpy_internal;
730 assert(PyUnicode_Check(obj));
731 _numpy_internal = PyImport_ImportModule("numpy.core._internal");
732 if (_numpy_internal == NULL) {
733 return NULL;
734 }
735 listobj = PyObject_CallMethod(_numpy_internal, "_commastring", "O", obj);
736 Py_DECREF(_numpy_internal);
737 if (listobj == NULL) {
738 return NULL;
739 }
740 if (!PyList_Check(listobj) || PyList_GET_SIZE(listobj) < 1) {
741 PyErr_SetString(PyExc_RuntimeError,
742 "_commastring is not returning a list with len >= 1");
743 Py_DECREF(listobj);
744 return NULL;
745 }
746 if (PyList_GET_SIZE(listobj) == 1) {
747 res = _convert_from_any(PyList_GET_ITEM(listobj, 0), align);
748 }
749 else {
750 res = _convert_from_list(listobj, align);
751 }
752 Py_DECREF(listobj);
753 return res;
754}
755
756static int
757_is_tuple_of_integers(PyObject *obj)

Callers 1

_convert_from_strFunction · 0.85

Calls 2

_convert_from_anyFunction · 0.85
_convert_from_listFunction · 0.85

Tested by

no test coverage detected