If the input is a zero dimensional PyArray return it converted to a scalar. Otherwise return the input and increment its reference count. Users must Py_DECREF the output of this method.
| 69 | // Otherwise return the input and increment its reference count. |
| 70 | // Users must Py_DECREF the output of this method. |
| 71 | PyObject* ZeroDimArrayToScalar(PyObject* obj) { |
| 72 | if (PyArray_IsZeroDim(obj) && !PyArray_IsScalar(obj, Generic)) { |
| 73 | auto pyarray_obj = reinterpret_cast<PyArrayObject*>(obj); |
| 74 | obj = PyArray_ToScalar(PyArray_DATA(pyarray_obj), pyarray_obj); |
| 75 | } else { |
| 76 | Py_INCREF(obj); |
| 77 | } |
| 78 | return obj; |
| 79 | } |
| 80 | |
| 81 | // Converts Python object `c` that should hold a Python string into a |
| 82 | // C++ string in *out. Returns nullptr on success, or a message on error. |
no outgoing calls
no test coverage detected