Skip to content

Commit 84b52e4

Browse files
authored
Merge pull request #77 from SylvainCorlay/pyvectorize-fix
Fix generalized copy constructor
2 parents adf3ab5 + b4bc2a8 commit 84b52e4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

include/xtensor-python/pyarray.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ namespace xt
362362
template <class E>
363363
inline pyarray<T>::pyarray(const xexpression<E>& e)
364364
{
365+
shape_type shape = forward_sequence<shape_type>(e.derived_cast().shape());
366+
strides_type strides = make_sequence<strides_type>(shape.size(), size_type(0));
367+
compute_strides(shape, layout::row_major, strides);
368+
init_array(shape, strides);
365369
semantic_base::assign(e);
366370
}
367371

include/xtensor-python/pytensor.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ namespace xt
289289
template <class E>
290290
inline pytensor<T, N>::pytensor(const xexpression<E>& e)
291291
{
292+
shape_type shape = forward_sequence<shape_type>(e.derived_cast().shape());
293+
strides_type strides = make_sequence<strides_type>(N, size_type(0));
294+
compute_strides(shape, layout::row_major, strides);
295+
init_array(shape, strides);
292296
semantic_base::assign(e);
293297
}
294298

0 commit comments

Comments
 (0)