8000 Merge pull request #250 from adriendelsalle/fix-pyarray · SylvainCorlay/xtensor-python@062c8c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 062c8c2

Browse files
authored
Merge pull request xtensor-stack#250 from adriendelsalle/fix-pyarray
fix pyarray column_major from xexpression
2 parents 9308c8f + 478a91a commit 062c8c2

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

include/xtensor-python/pyarray.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ namespace xt
443443
// TODO: prevent intermediary shape allocation
444444
shape_type shape = xtl::forward_sequence<shape_type, decltype(e.derived_cast().shape())>(e.derived_cast().shape());
445445
strides_type strides = xtl::make_sequence<strides_type>(shape.size(), size_type(0));
446-
compute_strides(shape, layout_type::row_major, strides);
446+
compute_strides(shape, L, strides);
447447
init_array(shape, strides);
448448
semantic_base::assign(e);
449449
}

test/test_pyarray.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,18 @@ namespace xt
181181
EXPECT_EQ(c(0, 1), a1(0, 1) + a2(0, 1));
182182
EXPECT_EQ(c(1, 0), a1(1, 0) + a2(1, 0));
183183
EXPECT_EQ(c(1, 1), a1(1, 1) + a2(1, 1));
184+
185+
pyarray<int, xt::layout_type::row_major> d = a1 + a2;
186+
EXPECT_EQ(d(0, 0), a1(0, 0) + a2(0, 0));
187+
EXPECT_EQ(d(0, 1), a1(0, 1) + a2(0, 1));
188+
EXPECT_EQ(d(1, 0), a1(1, 0) + a2(1, 0));
189+
EXPECT_EQ(d(1, 1), a1(1, 1) + a2(1, 1));
190+
191+
pyarray<int, xt::layout_type::column_major> e = a1 + a2;
192+
EXPECT_EQ(e(0, 0), a1(0, 0) + a2(0, 0));
193+
EXPECT_EQ(e(0, 1), a1(0, 1) + a2(0, 1));
194+
EXPECT_EQ(e(1, 0), a1(1, 0) + a2(1, 0));
195+
EXPECT_EQ(e(1, 1), a1(1, 1) + a2(1, 1));
184196
}
185197

186198
TEST(pyarray, resize)

0 commit comments

Comments
 (0)
0