Skip to content

Commit 478a91a

Browse files
fix pyarray column_major from xexpression
1 parent 9308c8f commit 478a91a

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy