File tree Expand file tree Collapse file tree 3 files changed +14
-0
lines changed
Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ namespace pybind11
3131{
3232 namespace detail
3333 {
34+ #ifdef PYBIND11_DESCR // The macro is removed from pybind11 since 2.3
3435 template <class T , xt::layout_type L>
3536 struct handle_type_name <xt::pyarray<T, L>>
3637 {
@@ -39,6 +40,7 @@ namespace pybind11
3940 return _ (" numpy.ndarray[" ) + npy_format_descriptor<T>::name () + _ (" ]" );
4041 }
4142 };
43+ #endif
4244
4345 template <typename T, xt::layout_type L>
4446 struct pyobject_caster <xt::pyarray<T, L>>
@@ -63,7 +65,11 @@ namespace pybind11
6365 return src.inc_ref ();
6466 }
6567
68+ #ifdef PYBIND11_DESCR // The macro is removed from pybind11 since 2.3
6669 PYBIND11_TYPE_CASTER (type, handle_type_name<type>::name());
70+ #else
71+ PYBIND11_TYPE_CASTER (type, _(" numpy.ndarray[" ) + npy_format_descriptor<T>::name + _(" ]" ));
72+ #endif
6773 };
6874
6975 // Type caster for casting ndarray to xexpression<pyarray>
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ namespace pybind11
3232{
3333 namespace detail
3434 {
35+ #ifdef PYBIND11_DESCR // The macro is removed from pybind11 since 2.3
3536 template <class T , std::size_t N, xt::layout_type L>
3637 struct handle_type_name <xt::pytensor<T, N, L>>
3738 {
@@ -40,6 +41,7 @@ namespace pybind11
4041 return _ (" numpy.ndarray[" ) + npy_format_descriptor<T>::name () + _ (" ]" );
4142 }
4243 };
44+ #endif
4345
4446 template <class T , std::size_t N, xt::layout_type L>
4547 struct pyobject_caster <xt::pytensor<T, N, L>>
@@ -65,7 +67,11 @@ namespace pybind11
6567 return src.inc_ref ();
6668 }
6769
70+ #ifdef PYBIND11_DESCR // The macro is removed from pybind11 since 2.3
6871 PYBIND11_TYPE_CASTER (type, handle_type_name<type>::name());
72+ #else
73+ PYBIND11_TYPE_CASTER (type, _(" numpy.ndarray[" ) + npy_format_descriptor<T>::name + _(" ]" ));
74+ #endif
6975 };
7076
7177 // Type caster for casting ndarray to xexpression<pytensor>
Original file line number Diff line number Diff line change @@ -157,10 +157,12 @@ namespace pybind11
157157 return cast_impl (src, policy, parent);
158158 }
159159
160+ #ifdef PYBIND11_DESCR // The macro is removed from pybind11 since 2.3
160161 static PYBIND11_DESCR name ()
161162 {
162163 return _ (" xt::xtensor" );
163164 }
165+ #endif
164166
165167 template <typename T>
166168 using cast_op_type = cast_op_type<T>;
You can’t perform that action at this time.
0 commit comments