File tree Expand file tree Collapse file tree 4 files changed +19
-2
lines changed
Expand file tree Collapse file tree 4 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -328,6 +328,7 @@ namespace xt
328328 using const_reference = typename base_type::const_reference;
329329 using pointer = typename base_type::pointer;
330330 using size_type = typename base_type::size_type;
331+ using difference_type = typename base_type::difference_type;
331332 using shape_type = typename base_type::shape_type;
332333 using strides_type = typename base_type::strides_type;
333334 using backstrides_type = typename base_type::backstrides_type;
@@ -745,7 +746,7 @@ namespace xt
745746 {
746747 m_shape = inner_shape_type (reinterpret_cast <size_type*>(PyArray_SHAPE (this ->python_array ())),
747748 static_cast <size_type>(PyArray_NDIM (this ->python_array ())));
748- m_strides = inner_strides_type (reinterpret_cast <size_type *>(PyArray_STRIDES (this ->python_array ())),
749+ m_strides = inner_strides_type (reinterpret_cast <difference_type *>(PyArray_STRIDES (this ->python_array ())),
749750 static_cast <size_type>(PyArray_NDIM (this ->python_array ())));
750751
751752 if (L != layout_type::dynamic && !do_strides_match (m_shape, m_strides, L))
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ namespace xt
2727 {
2828 public:
2929
30- using value_type = std::size_t ;
30+ using value_type = std::ptrdiff_t ;
3131 using const_reference = value_type;
3232 using const_pointer = const value_type*;
3333 using size_type = std::size_t ;
Original file line number Diff line number Diff line change 1111#include " xtensor-python/pyarray.hpp"
1212
1313#include " xtensor/xarray.hpp"
14+ #include " xtensor/xview.hpp"
1415
1516#include " test_common.hpp"
1617
@@ -241,4 +242,11 @@ namespace xt
241242 EXPECT_TRUE (std::equal (sc2.begin (), sc2.end (), a.shape ().begin ()) && a.shape ().size () == 1 );
242243 EXPECT_EQ (ptr, a.data ());
243244 }
245+
246+ TEST (pyarray, view)
247+ {
248+ xt::pyarray<int > arr = xt::zeros<int >({ 10 });
249+ auto v = xt::view (arr, xt::all ());
250+ EXPECT_EQ (v (0 ), 0 .);
251+ }
244252}
Original file line number Diff line number Diff line change 1111#include " xtensor-python/pytensor.hpp"
1212
1313#include " xtensor/xtensor.hpp"
14+ #include " xtensor/xview.hpp"
1415
1516#include " test_common.hpp"
1617
@@ -231,4 +232,11 @@ namespace xt
231232 // and the second element is `0`.
232233 EXPECT_THROW (a.reshape ({6 , 5 }), std::runtime_error);
233234 }
235+
236+ TEST (pytensor, view)
237+ {
238+ xt::pytensor<int , 1 > arr = xt::zeros<int >({ 10 });
239+ auto v = xt::view (arr, xt::all ());
240+ EXPECT_EQ (v (0 ), 0 .);
241+ }
234242}
You can’t perform that action at this time.
0 commit comments