Could anyone tell me how to check the data type of an ndarray that has been passed to C code?
In the concrete example I would like to call a different function if the datatype of the array is float32 or double/float64. So something like
if( Dtype(MyArray) == NPY_FLOAT )
{
DoSomething_float( MyArray );
}
else
{
DoSomething_double( MyArray );
}
I already found
PyTypeNum_ISFLOAT(num)
PyDataType_ISFLOAT(descr)
PyArray_ISFLOAT(obj)
In the numpy C API, but I don’t understand how to use those. I’ve already tried to find an instructive example but have found none.
you are almost there, as you are looking for
PyArray_TYPE: