diff --git a/.github/workflows/macos-linux-conda.yml b/.github/workflows/macos-linux-conda.yml new file mode 100644 index 0000000000000000000000000000000000000000..e71d3a22bd706447d24008215fe13b48deb88c10 --- /dev/null +++ b/.github/workflows/macos-linux-conda.yml @@ -0,0 +1,55 @@ +name: CI - EigenPy for Mac OS X/Linux via Conda + +on: [push,pull_request] + +jobs: + eigenpy-conda: + name: CI - EigenPy on ${{ matrix.os }} via Conda + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: ["ubuntu-latest", "macos-latest"] + + steps: + - uses: actions/checkout@v2 + + - name: Checkout submodules + run: | + git submodule update --init + + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: eigenpy + auto-update-conda: true + environment-file: .github/workflows/conda/environment.yml + python-version: 3.8 + + - name: Install cmake and update conda + shell: bash -l {0} + run: | + conda activate eigenpy + conda install cmake -c main + + - name: Build EigenPy + shell: bash -l {0} + run: | + conda activate eigenpy + echo $CONDA_PREFIX + + mkdir build + cd build + + cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$(which python3) + make + make build_tests + export CTEST_OUTPUT_ON_FAILURE=1 + make test + make install + + - name: Uninstall EigenPy + shell: bash -l {0} + run: | + cd build + make uninstall diff --git a/cmake b/cmake index ef309d5a23037324b48749ab8faf30846dc0e7f0..3a52692a40839b10f38352c1b06ccfebc0b53f36 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit ef309d5a23037324b48749ab8faf30846dc0e7f0 +Subproject commit 3a52692a40839b10f38352c1b06ccfebc0b53f36 diff --git a/include/eigenpy/numpy.hpp b/include/eigenpy/numpy.hpp index 8bb32150bdd718fbd8b6a068af9c2e3a43f08533..1631a79752cf1153589f0886fb3e4b25cf0fac38 100644 --- a/include/eigenpy/numpy.hpp +++ b/include/eigenpy/numpy.hpp @@ -21,10 +21,10 @@ #if defined _WIN32 || defined __CYGWIN__ #define EIGENPY_GET_PY_ARRAY_TYPE(array) \ - call_PyArray_ObjectType(reinterpret_cast<PyObject *>(array), 0) + call_PyArray_MinScalarType(array)->type_num #else #define EIGENPY_GET_PY_ARRAY_TYPE(array) \ - PyArray_ObjectType(reinterpret_cast<PyObject *>(array), 0) + PyArray_MinScalarType(array)->type_num #endif namespace eigenpy @@ -51,6 +51,10 @@ namespace eigenpy EIGENPY_DLLAPI void call_PyArray_InitArrFuncs(PyArray_ArrFuncs * funcs); EIGENPY_DLLAPI int call_PyArray_RegisterDataType(PyArray_Descr * dtype); + + EIGENPY_DLLAPI int call_PyArray_RegisterCanCast(PyArray_Descr *descr, int totype, NPY_SCALARKIND scalar); + + EIGENPY_DLLAPI PyArray_Descr * call_PyArray_MinScalarType(PyArrayObject *arr); } #else #define call_PyArray_Check(py_obj) PyArray_Check(py_obj) @@ -59,8 +63,10 @@ namespace eigenpy PyArray_New(py_type_ptr,nd,shape,np_type,NULL,data_ptr,0,options,NULL) #define getPyArrayType() &PyArray_Type #define call_PyArray_DescrFromType(typenum) PyArray_DescrFromType(typenum) + #define call_PyArray_MinScalarType(py_arr) PyArray_MinScalarType(py_arr) #define call_PyArray_InitArrFuncs(funcs) PyArray_InitArrFuncs(funcs) - #define call_PyArray_RegisterDataType(dtype) PyArray_RegisterDataType(dtype) + #define call_PyArray_RegisterDataType(dtype) PyArray_RegisterDataType(dtype) + #define call_PyArray_RegisterCanCast(descr,totype,scalar) PyArray_RegisterCanCast(descr,totype,scalar) #endif #endif // ifndef __eigenpy_numpy_hpp__ diff --git a/include/eigenpy/user-type.hpp b/include/eigenpy/user-type.hpp index 20c12cabf02f5b1bf7d79686298105534a61e224..27ac831ee8f1b829a46ec6b1144fdb16c4c6fd20 100644 --- a/include/eigenpy/user-type.hpp +++ b/include/eigenpy/user-type.hpp @@ -198,6 +198,9 @@ namespace eigenpy copyswap, copyswapn, dotfunc); + call_PyArray_RegisterCanCast(call_PyArray_DescrFromType(NPY_OBJECT), + code, NPY_NOSCALAR); + return code; } diff --git a/src/numpy.cpp b/src/numpy.cpp index 10c3d7ea0557a69616b4cbf6af0869d80f645605..fc132c9571fc550c821a01887df378d91fbf9623 100644 --- a/src/numpy.cpp +++ b/src/numpy.cpp @@ -58,6 +58,16 @@ namespace eigenpy { return PyArray_RegisterDataType(dtype); } + + PyArray_Descr * call_PyArray_MinScalarType(PyArrayObject * arr) + { + return PyArray_MinScalarType(arr); + } + + int call_PyArray_RegisterCanCast(PyArray_Descr *descr, int totype, NPY_SCALARKIND scalar) + { + return PyArray_RegisterCanCast(descr,totype,scalar); + } #endif }