Skip to content

Commit 275fd43

Browse files
authored
Merge pull request #228 from jcarpent/devel
Add CI for OSX
2 parents 503d7d6 + c3e322e commit 275fd43

File tree

5 files changed

+78
-4
lines changed

5 files changed

+78
-4
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: CI - EigenPy for Mac OS X/Linux via Conda
2+
3+
on: [push,pull_request]
4+
5+
jobs:
6+
eigenpy-conda:
7+
name: CI - EigenPy on ${{ matrix.os }} via Conda
8+
runs-on: ${{ matrix.os }}
9+
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
os: ["ubuntu-latest", "macos-latest"]
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: Checkout submodules
19+
run: |
20+
git submodule update --init
21+
22+
- uses: conda-incubator/setup-miniconda@v2
23+
with:
24+
activate-environment: eigenpy
25+
auto-update-conda: true
26+
environment-file: .github/workflows/conda/environment.yml
27+
python-version: 3.8
28+
29+
- name: Install cmake and update conda
30+
shell: bash -l {0}
31+
run: |
32+
conda activate eigenpy
33+
conda install cmake -c main
34+
35+
- name: Build EigenPy
36+
shell: bash -l {0}
37+
run: |
38+
conda activate eigenpy
39+
echo $CONDA_PREFIX
40+
41+
mkdir build
42+
cd build
43+
44+
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$(which python3)
45+
make
46+
make build_tests
47+
export CTEST_OUTPUT_ON_FAILURE=1
48+
make test
49+
make install
50+
51+
- name: Uninstall EigenPy
52+
shell: bash -l {0}
53+
run: |
54+
cd build
55+
make uninstall

include/eigenpy/numpy.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121

2222
#if defined _WIN32 || defined __CYGWIN__
2323
#define EIGENPY_GET_PY_ARRAY_TYPE(array) \
24-
call_PyArray_ObjectType(reinterpret_cast<PyObject *>(array), 0)
24+
call_PyArray_MinScalarType(array)->type_num
2525
#else
2626
#define EIGENPY_GET_PY_ARRAY_TYPE(array) \
27-
PyArray_ObjectType(reinterpret_cast<PyObject *>(array), 0)
27+
PyArray_MinScalarType(array)->type_num
2828
#endif
2929

3030
namespace eigenpy
@@ -51,6 +51,10 @@ namespace eigenpy
5151
EIGENPY_DLLAPI void call_PyArray_InitArrFuncs(PyArray_ArrFuncs * funcs);
5252

5353
EIGENPY_DLLAPI int call_PyArray_RegisterDataType(PyArray_Descr * dtype);
54+
55+
EIGENPY_DLLAPI int call_PyArray_RegisterCanCast(PyArray_Descr *descr, int totype, NPY_SCALARKIND scalar);
56+
57+
EIGENPY_DLLAPI PyArray_Descr * call_PyArray_MinScalarType(PyArrayObject *arr);
5458
}
5559
#else
5660
#define call_PyArray_Check(py_obj) PyArray_Check(py_obj)
@@ -59,8 +63,10 @@ namespace eigenpy
5963
PyArray_New(py_type_ptr,nd,shape,np_type,NULL,data_ptr,0,options,NULL)
6064
#define getPyArrayType() &PyArray_Type
6165
#define call_PyArray_DescrFromType(typenum) PyArray_DescrFromType(typenum)
66+
#define call_PyArray_MinScalarType(py_arr) PyArray_MinScalarType(py_arr)
6267
#define call_PyArray_InitArrFuncs(funcs) PyArray_InitArrFuncs(funcs)
63-
#define call_PyArray_RegisterDataType(dtype) PyArray_RegisterDataType(dtype)
68+
#define call_PyArray_RegisterDataType(dtype) PyArray_RegisterDataType(dtype)
69+
#define call_PyArray_RegisterCanCast(descr,totype,scalar) PyArray_RegisterCanCast(descr,totype,scalar)
6470
#endif
6571

6672
#endif // ifndef __eigenpy_numpy_hpp__

include/eigenpy/user-type.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ namespace eigenpy
198198
copyswap, copyswapn,
199199
dotfunc);
200200

201+
call_PyArray_RegisterCanCast(call_PyArray_DescrFromType(NPY_OBJECT),
202+
code, NPY_NOSCALAR);
203+
201204
return code;
202205
}
203206

src/numpy.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ namespace eigenpy
5858
{
5959
return PyArray_RegisterDataType(dtype);
6060
}
61+
62+
PyArray_Descr * call_PyArray_MinScalarType(PyArrayObject * arr)
63+
{
64+
return PyArray_MinScalarType(arr);
65+
}
66+
67+
int call_PyArray_RegisterCanCast(PyArray_Descr *descr, int totype, NPY_SCALARKIND scalar)
68+
{
69+
return PyArray_RegisterCanCast(descr,totype,scalar);
70+
}
6171

6272
#endif
6373
}

0 commit comments

Comments
 (0)