diff --git a/.github/workflows/windows-conda.yml b/.github/workflows/windows-conda.yml index 6b5d6aa18408fb445e926dd0b849bea925ce7146..10a7dd5ee22e07902168a074d33580db9eb022c3 100644 --- a/.github/workflows/windows-conda.yml +++ b/.github/workflows/windows-conda.yml @@ -47,6 +47,10 @@ jobs: :: Build and Install cmake --build . --config Release --target install + :: Build stubs + git clone https://github.com/jcarpent/pybind11-stubgen.git + python "%CD%\pybind11-stubgen\pybind11_stubgen\__init__.py" -o %CONDA_PREFIX%\Lib\site-packages\eigenpy eigenpy --boost-python --ignore-invalid signature --no-setup-py --root-module-suffix "" + :: Testing ctest --output-on-failure -C Release -V diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a41d7fad988abbc948b9a2d5abf1b7482a5ae10..9226fdc5435e80fa91002b8caefc492b21472a2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,16 +62,16 @@ FIND_NUMPY() IF(WIN32) LINK_DIRECTORIES(${PYTHON_LIBRARY_DIRS}) - # Set default Windows build paths - SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY - ${PROJECT_BINARY_DIR}/Bin - CACHE PATH "Single directory for all libraries") - SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY - ${PROJECT_BINARY_DIR}/Bin - CACHE PATH "Single directory for all executables") - SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY - ${PROJECT_BINARY_DIR}/Bin - CACHE PATH "Sing$le directory for all archives") +# # Set default Windows build paths +# SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY +# ${PROJECT_BINARY_DIR}/Bin +# CACHE PATH "Single directory for all libraries") +# SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY +# ${PROJECT_BINARY_DIR}/Bin +# CACHE PATH "Single directory for all executables") +# SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY +# ${PROJECT_BINARY_DIR}/Bin +# CACHE PATH "Sing$le directory for all archives") ENDIF(WIN32) # ---------------------------------------------------- diff --git a/include/eigenpy/numpy.hpp b/include/eigenpy/numpy.hpp index 84c7575d7db74559b0807246e47279d1cf01b20e..8269136fccdc952696dc3139a772d05418ac1ff7 100644 --- a/include/eigenpy/numpy.hpp +++ b/include/eigenpy/numpy.hpp @@ -44,12 +44,13 @@ namespace eigenpy template <> struct NumpyEquivalentType<bool> { enum { type_code = NPY_BOOL };}; template <> struct NumpyEquivalentType<int> { enum { type_code = NPY_INT };}; template <> struct NumpyEquivalentType<unsigned int> { enum { type_code = NPY_UINT };}; -#if __APPLE__ - template <> struct NumpyEquivalentType<long> { enum { type_code = NPY_INT64 };}; -#endif + template <> struct NumpyEquivalentType<long> { enum { type_code = NPY_LONG };}; +//#if defined _WIN32 || defined __CYGWIN__ + template <> struct NumpyEquivalentType<long long> { enum { type_code = NPY_LONGLONG };}; +//#else +// template <> struct NumpyEquivalentType<long long> { enum { type_code = NPY_LONGLONG };}; +//#endif template <> struct NumpyEquivalentType<unsigned long> { enum { type_code = NPY_ULONG };}; - template <> struct NumpyEquivalentType<int64_t> { enum { type_code = NPY_INT64 };}; -// template <> struct NumpyEquivalentType<long long> { enum { type_code = NPY_LONGLONG };}; template<typename Scalar> bool isNumpyNativeType() diff --git a/include/eigenpy/user-type.hpp b/include/eigenpy/user-type.hpp index 8c194886690430248072a55565133fc98dd1e79b..ed49ceb21fc10c72b29dd31ea015f6c1f1719fe1 100644 --- a/include/eigenpy/user-type.hpp +++ b/include/eigenpy/user-type.hpp @@ -9,6 +9,8 @@ #include "eigenpy/numpy-type.hpp" #include "eigenpy/register.hpp" +#include <iostream> + namespace eigenpy { /// \brief Default cast algo to cast a From to To. Can be specialized for any types. @@ -256,6 +258,11 @@ namespace eigenpy assert(to_typenum >= 0 && "to_typenum is not valid"); assert(from_array_descr != NULL && "from_array_descr is not valid"); + std::cout << "From: " << bp::type_info(typeid(From)).name() << " " << Register::getTypeCode<From>() + << " to: " << bp::type_info(typeid(To)).name() << " " << Register::getTypeCode<To>() + << "\n to_typenum: " << to_typenum + << std::endl; + if(call_PyArray_RegisterCastFunc(from_array_descr, to_typenum, static_cast<PyArray_VectorUnaryFunc *>(&eigenpy::internal::cast<From,To>)) < 0) diff --git a/unittest/python/test_MINRES.py b/unittest/python/test_MINRES.py index 67cbfac96376ed56e3841dc99868467326318956..307ab3c513c3bbac1582b6360e9e54b8fd16a9d1 100644 --- a/unittest/python/test_MINRES.py +++ b/unittest/python/test_MINRES.py @@ -11,4 +11,6 @@ minres = eigenpy.MINRES(A) X = np.random.rand(dim,20) B = A.dot(X) X_est = minres.solve(B) +print("A.dot(X_est):",A.dot(X_est)) +print("B:",B) assert eigenpy.is_approx(A.dot(X_est),B,1e-6) diff --git a/unittest/python/test_user_type.py b/unittest/python/test_user_type.py index 316c03147e34ef8f8e5899fda0fc32ac30364f5e..956108d395ad6c61a5bd9d5723d3bdf52ce8e811 100644 --- a/unittest/python/test_user_type.py +++ b/unittest/python/test_user_type.py @@ -6,13 +6,13 @@ rows = 10 cols = 20 def test(dtype): - mat = np.ones((rows,cols),dtype=dtype) + mat = np.array(np.ones((rows,cols)).astype(np.intc),dtype=dtype) mat = np.random.rand(rows,cols).astype(dtype) mat_copy = mat.copy() assert (mat == mat_copy).all() assert not (mat != mat_copy).all() -# if version.parse(np.__version__) >= version.parse("1.21.0"): # check if it fixes for new versio of NumPy +# if version.parse(np.__version__) >= version.parse("1.21.0"): # check if it fixes for new versio of NumPy # mat.fill(mat.dtype.type(20.)) # mat_copy = mat.copy() # assert((mat == mat_copy).all()) @@ -20,7 +20,7 @@ def test(dtype): mat_op = mat + mat mat_op = mat.copy(order='F') + mat.copy(order='C') - + mat_op = mat - mat mat_op = mat * mat mat_op = mat.dot(mat.T) @@ -45,7 +45,7 @@ def test_cast(from_dtype,to_dtype): from_mat = np.zeros((rows,cols),dtype=from_dtype) to_mat = from_mat.astype(dtype=to_dtype) - + test(user_type.CustomDouble) test_cast(user_type.CustomDouble,np.double) diff --git a/unittest/user_type.cpp b/unittest/user_type.cpp index 22bc566061a473ccedeae064b9dc10ffded9bbc4..bad7bc042ae879d10c461a0906d6a8ff3b0f55da 100644 --- a/unittest/user_type.cpp +++ b/unittest/user_type.cpp @@ -196,14 +196,20 @@ BOOST_PYTHON_MODULE(user_type) eigenpy::registerCast<DoubleType,double>(true); eigenpy::registerCast<double,DoubleType>(true); - eigenpy::registerCast<DoubleType,int32_t>(false); - eigenpy::registerCast<int32_t,DoubleType>(true); - eigenpy::registerCast<DoubleType,int64_t>(false); - eigenpy::registerCast<int64_t,DoubleType>(true); + eigenpy::registerCast<DoubleType,int>(false); + eigenpy::registerCast<int,DoubleType>(true); + eigenpy::registerCast<DoubleType,long long>(false); + eigenpy::registerCast<long long,DoubleType>(true); + eigenpy::registerCast<DoubleType,long>(false); + eigenpy::registerCast<long,DoubleType>(true); eigenpy::registerCast<FloatType,double>(true); eigenpy::registerCast<double,FloatType>(false); - eigenpy::registerCast<FloatType,int64_t>(false); - eigenpy::registerCast<int64_t,FloatType>(true); + eigenpy::registerCast<FloatType,long long>(false); + eigenpy::registerCast<long long,FloatType>(true); + eigenpy::registerCast<FloatType,int>(false); + eigenpy::registerCast<int,FloatType>(true); + eigenpy::registerCast<FloatType,long>(false); + eigenpy::registerCast<long,FloatType>(true); bp::implicitly_convertible<double,DoubleType>(); bp::implicitly_convertible<DoubleType,double>();