Verified Commit d1b68776 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

core: export call_PyArray_RegisterCastFunc

Needed by Windows
parent 950963c6
Pipeline #15425 failed with stage
in 12 minutes and 16 seconds
......@@ -83,6 +83,8 @@ namespace eigenpy
EIGENPY_DLLAPI int call_PyArray_RegisterCanCast(PyArray_Descr *descr, int totype, NPY_SCALARKIND scalar);
EIGENPY_DLLAPI PyArray_Descr * call_PyArray_MinScalarType(PyArrayObject *arr);
EIGENPY_DLLAPI int call_PyArray_RegisterCastFunc(PyArray_Descr* descr, int totype, PyArray_VectorUnaryFunc* castfunc);
}
#else
#define call_PyArray_Check(py_obj) PyArray_Check(py_obj)
......@@ -95,6 +97,7 @@ namespace eigenpy
#define call_PyArray_InitArrFuncs(funcs) PyArray_InitArrFuncs(funcs)
#define call_PyArray_RegisterDataType(dtype) PyArray_RegisterDataType(dtype)
#define call_PyArray_RegisterCanCast(descr,totype,scalar) PyArray_RegisterCanCast(descr,totype,scalar)
#define call_PyArray_RegisterCastFunc(descr,totype,castfunc) PyArray_RegisterCastFunc(descr,totype,castfunc)
#endif
#endif // ifndef __eigenpy_numpy_hpp__
......@@ -257,11 +257,11 @@ namespace eigenpy
// PyTypeObject * to_py_type = Register::getPyType<To>();
int to_typenum = Register::getTypeCode<To>();
assert(to_typenum >= 0 && "to_typenum is not valid");
assert(from_array_descr != NULL && "to_typenum is not valid");
assert(from_array_descr != NULL && "from_array_descr is not valid");
if(PyArray_RegisterCastFunc(from_array_descr,
to_typenum,
static_cast<PyArray_VectorUnaryFunc *>(&eigenpy::internal::cast<From,To>)) < 0)
if(call_PyArray_RegisterCastFunc(from_array_descr,
to_typenum,
static_cast<PyArray_VectorUnaryFunc *>(&eigenpy::internal::cast<From,To>)) < 0)
{
std::stringstream ss;
ss
......@@ -274,9 +274,9 @@ namespace eigenpy
return false;
}
if (safe && PyArray_RegisterCanCast(from_array_descr,
to_typenum,
NPY_NOSCALAR) < 0)
if (safe && call_PyArray_RegisterCanCast(from_array_descr,
to_typenum,
NPY_NOSCALAR) < 0)
{
std::stringstream ss;
ss
......
/*
* Copyright 2020 INRIA
* Copyright 2020-2021 INRIA
*/
#include "eigenpy/numpy.hpp"
......@@ -68,6 +68,11 @@ namespace eigenpy
{
return PyArray_RegisterCanCast(descr,totype,scalar);
}
int call_PyArray_RegisterCastFunc(PyArray_Descr* descr, int totype, PyArray_VectorUnaryFunc* castfunc)
{
return PyArray_RegisterCastFunc(descr,totype,castfunc);
}
#endif
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment