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

Function PyArray_ScalarKind

numpy/core/src/multiarray/multiarraymodule.c:812–835  ·  view source on GitHub ↗

NUMPY_API * ScalarKind * * Returns the scalar kind of a type number, with an * optional tweak based on the scalar value itself. * If no scalar is provided, it returns INTPOS_SCALAR * for both signed and unsigned integers, otherwise * it checks the sign of any signed integer to choose * INTNEG_SCALAR when appropriate. */

Source from the content-addressed store, hash-verified

810 * INTNEG_SCALAR when appropriate.
811 */
812NPY_NO_EXPORT NPY_SCALARKIND
813PyArray_ScalarKind(int typenum, PyArrayObject **arr)
814{
815 NPY_SCALARKIND ret = NPY_NOSCALAR;
816
817 if ((unsigned int)typenum < NPY_NTYPES) {
818 ret = _npy_scalar_kinds_table[typenum];
819 /* Signed integer types are INTNEG in the table */
820 if (ret == NPY_INTNEG_SCALAR) {
821 if (!arr || !_signbit_set(*arr)) {
822 ret = NPY_INTPOS_SCALAR;
823 }
824 }
825 } else if (PyTypeNum_ISUSERDEF(typenum)) {
826 PyArray_Descr* descr = PyArray_DescrFromType(typenum);
827
828 if (descr->f->scalarkind) {
829 ret = descr->f->scalarkind((arr ? *arr : NULL));
830 }
831 Py_DECREF(descr);
832 }
833
834 return ret;
835}
836
837/*NUMPY_API
838 *

Callers 1

PyArray_ClipFunction · 0.85

Calls 1

_signbit_setFunction · 0.85

Tested by

no test coverage detected