Created
June 30, 2015 01:47
-
-
Save eayoungs/cb0a6896a37008ad11e8 to your computer and use it in GitHub Desktop.
C function used by numpy multiply function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static PyObject * | |
_vec_string(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds) | |
{ | |
PyArrayObject* char_array = NULL; | |
PyArray_Descr *type = NULL; | |
PyObject* method_name; | |
PyObject* args_seq = NULL; | |
PyObject* method = NULL; | |
PyObject* result = NULL; | |
if (!PyArg_ParseTuple(args, "O&O&O|O", | |
PyArray_Converter, &char_array, | |
PyArray_DescrConverter, &type, | |
&method_name, &args_seq)) { | |
goto err; | |
} | |
if (PyArray_TYPE(char_array) == NPY_STRING) { | |
method = PyObject_GetAttr((PyObject *)&PyString_Type, method_name); | |
} | |
else if (PyArray_TYPE(char_array) == NPY_UNICODE) { | |
method = PyObject_GetAttr((PyObject *)&PyUnicode_Type, method_name); | |
} | |
else { | |
PyErr_SetString(PyExc_TypeError, | |
"string operation on non-string array"); | |
goto err; | |
} | |
if (method == NULL) { | |
goto err; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment