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

Function int_sequence_to_arrays

numpy/core/src/multiarray/compiled_base.c:919–954  ·  view source on GitHub ↗

* Converts a Python sequence into 'count' PyArrayObjects * * seq - Input Python object, usually a tuple but any sequence works. * Must have integral content. * paramname - The name of the parameter that produced 'seq'. * count - How many arrays there should be (errors if it doesn't match). * op - Where the arrays are placed. */

Source from the content-addressed store, hash-verified

917 * op - Where the arrays are placed.
918 */
919static int int_sequence_to_arrays(PyObject *seq,
920 char *paramname,
921 int count,
922 PyArrayObject **op
923 )
924{
925 int i;
926
927 if (!PySequence_Check(seq) || PySequence_Size(seq) != count) {
928 PyErr_Format(PyExc_ValueError,
929 "parameter %s must be a sequence of length %d",
930 paramname, count);
931 return -1;
932 }
933
934 for (i = 0; i < count; ++i) {
935 PyObject *item = PySequence_GetItem(seq, i);
936 if (item == NULL) {
937 goto fail;
938 }
939 op[i] = astype_anyint(item);
940 Py_DECREF(item);
941 if (op[i] == NULL) {
942 goto fail;
943 }
944 }
945
946 return 0;
947
948fail:
949 while (--i >= 0) {
950 Py_XDECREF(op[i]);
951 op[i] = NULL;
952 }
953 return -1;
954}
955
956/* Inner loop for ravel_multi_index */
957static int

Callers 1

arr_ravel_multi_indexFunction · 0.85

Calls 1

astype_anyintFunction · 0.85

Tested by

no test coverage detected