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

Function PyArray_CastScalarDirect

numpy/core/src/multiarray/scalarapi.c:211–224  ·  view source on GitHub ↗

NUMPY_API * Cast Scalar to c-type */

Source from the content-addressed store, hash-verified

209 * Cast Scalar to c-type
210 */
211NPY_NO_EXPORT int
212PyArray_CastScalarDirect(PyObject *scalar, PyArray_Descr *indescr,
213 void *ctypeptr, int outtype)
214{
215 PyArray_VectorUnaryFunc* castfunc;
216 void *ptr;
217 castfunc = PyArray_GetCastFunc(indescr, outtype);
218 if (castfunc == NULL) {
219 return -1;
220 }
221 ptr = scalar_value(scalar, indescr);
222 castfunc(ptr, ctypeptr, 1, NULL, NULL);
223 return 0;
224}
225
226/*NUMPY_API
227 * Get 0-dim array from scalar

Callers

nothing calls this directly

Calls 2

PyArray_GetCastFuncFunction · 0.85
scalar_valueFunction · 0.85

Tested by

no test coverage detected