| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c47abe0 commit 81674b1
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -225,7 +225,7 @@ namespace xt | |||
| 225 | 225 | template <class S> | |
| 226 | 226 | inline void pycontainer<D>::reshape(const S& shape) | |
| 227 | 227 | { | |
| 228 | - if (shape.size() != this->dimension() || !std::equal(shape.begin(), shape.end(), this->shape().begin())) | ||
| 228 | + if (shape.size() != this->dimension() || !std::equal(std::begin(shape), std::end(shape), std::begin(this->shape()))) | ||
| 229 | 229 | { | |
| 230 | 230 | reshape(shape, layout_type::row_major); | |
| 231 | 231 | } | |
@@ -254,7 +254,7 @@ namespace xt | |||
| 254 | 254 | template <class S> | |
| 255 | 255 | inline void pycontainer<D>::reshape(const S& shape, const strides_type& strides) | |
| 256 | 256 | { | |
| 257 | - derived_type tmp(shape, strides); | ||
| 257 | + derived_type tmp(xtl::forward_sequence<shape_type>(shape), strides); | ||
| 258 | 258 | *static_cast<derived_type*>(this) = std::move(tmp); | |
| 259 | 259 | } | |
| 260 | 260 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -130,7 +130,7 @@ namespace xt | |||
| 130 | 130 | m_data = {-1, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19}; | |
| 131 | 131 | m_layout = layout_type::dynamic; | |
| 132 | 132 | m_assigner.resize(m_shape[0]); | |
| 133 | - for (std::size_t i = 0; i < m_shape[0]; ++i) | ||
| 133 | + for (std::size_t i = 0; i < std::size_t(m_shape[0]); ++i) | ||
| 134 | 134 | { | |
| 135 | 135 | m_assigner[i].resize(m_shape[1]); | |
| 136 | 136 | } | |
@@ -184,10 +184,10 @@ namespace xt | |||
| 184 | 184 | auto v_copy_b = vec; | |
| 185 | 185 | std::array<std::size_t, 3> ar = {3, 2, 4}; | |
| 186 | 186 | std::vector<std::size_t> vr = {3, 2, 4}; | |
| 187 | - // v_copy_a.reshape(ar, true); | ||
| 188 | - // compare_shape(v_copy_a, rm); | ||
| 189 | - // v_copy_b.reshape(vr, true); | ||
| 190 | - // compare_shape(v_copy_b, rm); | ||
| 187 | + v_copy_a.reshape(ar); | ||
| 188 | + compare_shape(v_copy_a, rm); | ||
| 189 | + v_copy_b.reshape(vr); | ||
| 190 | + compare_shape(v_copy_b, rm); | ||
| 191 | 191 | } | |
| 192 | 192 | ||
| 193 | 193 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -161,6 +161,10 @@ namespace xt | |||
| 161 | 161 | { | |
| 162 | 162 | pyarray<int> a; | |
| 163 | 163 | test_reshape(a); | |
| 164 | + | ||
| 165 | + pyarray<int> b = { {1, 2}, {3, 4} }; | ||
| 166 | + a.reshape(b.shape()); | ||
| 167 | + EXPECT_EQ(a.shape(), b.shape()); | ||
| 164 | 168 | } | |
| 165 | 169 | ||
| 166 | 170 | TEST(pyarray, transpose) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -160,6 +160,10 @@ namespace xt | |||
| 160 | 160 | { | |
| 161 | 161 | pytensor<int, 3> a; | |
| 162 | 162 | test_reshape<pytensor<int, 3>, container_type>(a); | |
| 163 | + | ||
| 164 | + pytensor<int, 3> b = { { { 1, 2 },{ 3, 4 } } }; | ||
| 165 | + a.reshape(b.shape()); | ||
| 166 | + EXPECT_EQ(a.shape(), b.shape()); | ||
| 163 | 167 | } | |
| 164 | 168 | ||
| 165 | 169 | TEST(pytensor, transpose) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments