* 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
| 722 | * a good idea. This should all be converted to C code. |
| 723 | */ |
| 724 | static 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 | |
| 756 | static int |
| 757 | _is_tuple_of_integers(PyObject *obj) |
no test coverage detected