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

Function PyArray_CorrelatemodeConverter

numpy/core/src/multiarray/conversion_utils.c:867–895  ·  view source on GitHub ↗

* Convert an object to NPY_VALID / NPY_SAME / NPY_FULL */

Source from the content-addressed store, hash-verified

865 * Convert an object to NPY_VALID / NPY_SAME / NPY_FULL
866 */
867NPY_NO_EXPORT int
868PyArray_CorrelatemodeConverter(PyObject *object, NPY_CORRELATEMODE *val)
869{
870 if (PyUnicode_Check(object)) {
871 return string_converter_helper(
872 object, (void *)val, correlatemode_parser, "mode",
873 "must be one of 'valid', 'same', or 'full'");
874 }
875
876 else {
877 /* For users passing integers */
878 int number = PyArray_PyIntAsInt(object);
879 if (error_converting(number)) {
880 PyErr_SetString(PyExc_TypeError,
881 "convolve/correlate mode not understood");
882 return NPY_FAIL;
883 }
884 if (number <= (int) NPY_FULL
885 && number >= (int) NPY_VALID) {
886 *val = (NPY_CORRELATEMODE) number;
887 return NPY_SUCCEED;
888 }
889 else {
890 PyErr_Format(PyExc_ValueError,
891 "integer convolve/correlate mode must be 0, 1, or 2");
892 return NPY_FAIL;
893 }
894 }
895}
896
897static int casting_parser(char const *str, Py_ssize_t length, void *data)
898{

Callers

nothing calls this directly

Calls 2

string_converter_helperFunction · 0.85
PyArray_PyIntAsIntFunction · 0.85

Tested by

no test coverage detected