Skip to content

Commit 0f48d46

Browse files
author
Yoshiaki Bando
committed
Adapt type_caster to pybind11 2.1.1
1 parent 3799515 commit 0f48d46

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

include/xtensor-python/xtensor_type_caster_base.hpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ namespace pybind11
2828
template<typename Type>
2929
handle xtensor_array_cast(Type const &src, handle base = handle(), bool writeable = true)
3030
{
31-
std::vector<ssize_t> python_strides(src.strides().size());
32-
std::transform(src.strides().begin(), src.strides().end(), python_strides.data(),
31+
std::vector<size_t> python_strides(src.strides().size());
32+
std::transform(src.strides().begin(), src.strides().end(), python_strides.begin(),
3333
[](auto v) { return sizeof(typename Type::value_type) * v; });
3434

35-
array a(src.shape(), python_strides, src.begin(), base);
35+
std::vector<size_t> python_shape(src.shape().size());
36+
std::copy(src.shape().begin(), src.shape().end(), python_shape.begin());
37+
38+
array a(python_shape, python_strides, src.begin(), base);
3639

3740
if (!writeable)
3841
{
@@ -151,9 +154,9 @@ namespace pybind11
151154
}
152155

153156
template <typename T>
154-
using cast_op_type = movable_cast_op_type<T>;
157+
using cast_op_type = cast_op_type<T>;
155158
};
156159
}
157160
}
158161

159-
#endif
162+
#endif

0 commit comments

Comments
 (0)