Skip to content

Commit 59fd1a6

Browse files
authored
Merge pull request #462 from jorisv/topic/fix_eigen_tofrom_py
Fix EigenToPy/EigenFromPy on Windows
2 parents 4c69144 + b86a7d9 commit 59fd1a6

File tree

7 files changed

+66
-74
lines changed

7 files changed

+66
-74
lines changed

.github/workflows/macos-linux-conda.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
-DGENERATE_PYTHON_STUBS=ON \
103103
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
104104
-DCMAKE_CXX_FLAGS=${{ matrix.cxx_options }}
105-
cmake --build . -j4
105+
cmake --build . -j3
106106
ctest --output-on-failure
107107
cmake --install .
108108

.github/workflows/windows-conda.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
if errorlevel 1 exit 1
8080
8181
:: Build
82-
cmake --build . -j4
82+
cmake --build . -j3
8383
if errorlevel 1 exit 1
8484
8585
:: Testing

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

77
## [Unreleased]
88

9+
### Fixed
10+
- Allow EigenToPy/EigenFromPy specialization with CL compiler ([#462](https://github.com/stack-of-tasks/eigenpy/pull/462))
11+
912
## [3.5.0] - 2024-04-14
1013

1114
### Added

include/eigenpy/eigen-from-python.hpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +290,10 @@ struct eigen_from_py_impl<MatType, Eigen::MatrixBase<MatType> > {
290290
static void registration();
291291
};
292292

293-
#ifdef EIGENPY_MSVC_COMPILER
294-
template <typename EigenType>
295-
struct EigenFromPy<EigenType,
296-
typename boost::remove_reference<EigenType>::type::Scalar>
297-
#else
298-
template <typename EigenType, typename _Scalar>
299-
struct EigenFromPy
300-
#endif
301-
: eigen_from_py_impl<EigenType> {
302-
};
293+
template <typename EigenType,
294+
typename Scalar =
295+
typename boost::remove_reference<EigenType>::type::Scalar>
296+
struct EigenFromPy : eigen_from_py_impl<EigenType> {};
303297

304298
template <typename MatType>
305299
void *eigen_from_py_impl<MatType, Eigen::MatrixBase<MatType> >::convertible(

include/eigenpy/eigen-to-python.hpp

Lines changed: 50 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -16,51 +16,6 @@
1616
#include "eigenpy/scipy-type.hpp"
1717
#include "eigenpy/registration.hpp"
1818

19-
namespace boost {
20-
namespace python {
21-
22-
template <typename MatrixRef, class MakeHolder>
23-
struct to_python_indirect_eigen {
24-
template <class U>
25-
inline PyObject* operator()(U const& mat) const {
26-
return eigenpy::EigenToPy<MatrixRef>::convert(const_cast<U&>(mat));
27-
}
28-
29-
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
30-
inline PyTypeObject const* get_pytype() const {
31-
return converter::registered_pytype<MatrixRef>::get_pytype();
32-
}
33-
#endif
34-
};
35-
36-
template <typename Scalar, int RowsAtCompileTime, int ColsAtCompileTime,
37-
int Options, int MaxRowsAtCompileTime, int MaxColsAtCompileTime,
38-
class MakeHolder>
39-
struct to_python_indirect<
40-
Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, Options,
41-
MaxRowsAtCompileTime, MaxColsAtCompileTime>&,
42-
MakeHolder>
43-
: to_python_indirect_eigen<
44-
Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, Options,
45-
MaxRowsAtCompileTime, MaxColsAtCompileTime>&,
46-
MakeHolder> {};
47-
48-
template <typename Scalar, int RowsAtCompileTime, int ColsAtCompileTime,
49-
int Options, int MaxRowsAtCompileTime, int MaxColsAtCompileTime,
50-
class MakeHolder>
51-
struct to_python_indirect<
52-
const Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, Options,
53-
MaxRowsAtCompileTime, MaxColsAtCompileTime>&,
54-
MakeHolder>
55-
: to_python_indirect_eigen<
56-
const Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime,
57-
Options, MaxRowsAtCompileTime,
58-
MaxColsAtCompileTime>&,
59-
MakeHolder> {};
60-
61-
} // namespace python
62-
} // namespace boost
63-
6419
namespace eigenpy {
6520

6621
EIGENPY_DOCUMENTATION_START_IGNORE
@@ -202,23 +157,63 @@ struct eigen_to_py_impl_tensor {
202157

203158
EIGENPY_DOCUMENTATION_END_IGNORE
204159

205-
#ifdef EIGENPY_MSVC_COMPILER
206-
template <typename EigenType>
207-
struct EigenToPy<EigenType,
208-
typename boost::remove_reference<EigenType>::type::Scalar>
209-
#else
210-
template <typename EigenType, typename _Scalar>
211-
struct EigenToPy
212-
#endif
213-
: eigen_to_py_impl<EigenType> {
214-
};
160+
template <typename EigenType,
161+
typename Scalar =
162+
typename boost::remove_reference<EigenType>::type::Scalar>
163+
struct EigenToPy : eigen_to_py_impl<EigenType> {};
215164

216165
template <typename MatType>
217166
struct EigenToPyConverter {
218167
static void registration() {
219168
bp::to_python_converter<MatType, EigenToPy<MatType>, true>();
220169
}
221170
};
171+
222172
} // namespace eigenpy
223173

174+
namespace boost {
175+
namespace python {
176+
177+
template <typename MatrixRef, class MakeHolder>
178+
struct to_python_indirect_eigen {
179+
template <class U>
180+
inline PyObject* operator()(U const& mat) const {
181+
return eigenpy::EigenToPy<MatrixRef>::convert(const_cast<U&>(mat));
182+
}
183+
184+
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
185+
inline PyTypeObject const* get_pytype() const {
186+
return converter::registered_pytype<MatrixRef>::get_pytype();
187+
}
188+
#endif
189+
};
190+
191+
template <typename Scalar, int RowsAtCompileTime, int ColsAtCompileTime,
192+
int Options, int MaxRowsAtCompileTime, int MaxColsAtCompileTime,
193+
class MakeHolder>
194+
struct to_python_indirect<
195+
Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, Options,
196+
MaxRowsAtCompileTime, MaxColsAtCompileTime>&,
197+
MakeHolder>
198+
: to_python_indirect_eigen<
199+
Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, Options,
200+
MaxRowsAtCompileTime, MaxColsAtCompileTime>&,
201+
MakeHolder> {};
202+
203+
template <typename Scalar, int RowsAtCompileTime, int ColsAtCompileTime,
204+
int Options, int MaxRowsAtCompileTime, int MaxColsAtCompileTime,
205+
class MakeHolder>
206+
struct to_python_indirect<
207+
const Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, Options,
208+
MaxRowsAtCompileTime, MaxColsAtCompileTime>&,
209+
MakeHolder>
210+
: to_python_indirect_eigen<
211+
const Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime,
212+
Options, MaxRowsAtCompileTime,
213+
MaxColsAtCompileTime>&,
214+
MakeHolder> {};
215+
216+
} // namespace python
217+
} // namespace boost
218+
224219
#endif // __eigenpy_eigen_to_python_hpp__

include/eigenpy/fwd.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ namespace bp = boost::python;
125125
#endif
126126

127127
namespace eigenpy {
128-
template <typename MatType,
129-
typename Scalar =
130-
typename boost::remove_reference<MatType>::type::Scalar>
128+
129+
// Default Scalar value can't be defined in the declaration
130+
// because of a CL bug.
131+
// See https://github.com/stack-of-tasks/eigenpy/pull/462
132+
template <typename MatType, typename Scalar>
131133
struct EigenToPy;
132-
template <typename MatType,
133-
typename Scalar =
134-
typename boost::remove_reference<MatType>::type::Scalar>
134+
template <typename MatType, typename Scalar>
135135
struct EigenFromPy;
136136

137137
template <typename T>

include/eigenpy/register.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct EIGENPY_DLLAPI Register {
106106
static Register &instance();
107107

108108
private:
109-
Register(){};
109+
Register() {};
110110

111111
struct Compare_PyTypeObject {
112112
bool operator()(const PyTypeObject *a, const PyTypeObject *b) const {

0 commit comments

Comments
 (0)