@@ -38,45 +38,68 @@ namespace xt
38
38
TEST (pyarray, initializer_constructor)
39
39
{
40
40
pyarray<int > r
41
- {{{0 ,1 ,2 },
42
- {3 ,4 ,5 },
43
- {6 ,7 ,8 }},
44
- {{9 ,10 ,11 },
45
- {12 ,13 ,14 },
46
- {15 ,16 ,17 }}};
41
+ {{{0 ,1 ,2 },
42
+ {3 ,4 ,5 },
43
+ {6 ,7 ,8 }},
44
+ {{9 ,10 ,11 },
45
+ {12 ,13 ,14 },
46
+ {15 ,16 ,17 }}};
47
47
48
48
EXPECT_EQ (r.layout (), xt::layout_type::row_major);
49
49
EXPECT_EQ (r.dimension (),3 );
50
50
EXPECT_EQ (r (0 ,0 ,1 ),1 );
51
51
EXPECT_EQ (r.shape ()[0 ],2 );
52
52
53
53
pyarray<int , xt::layout_type::column_major> c
54
- {{{0 ,1 ,2 },
55
- {3 ,4 ,5 },
56
- {6 ,7 ,8 }},
57
- {{9 ,10 ,11 },
58
- {12 ,13 ,14 },
59
- {15 ,16 ,17 }}};
54
+ {{{0 ,1 ,2 },
55
+ {3 ,4 ,5 },
56
+ {6 ,7 ,8 }},
57
+ {{9 ,10 ,11 },
58
+ {12 ,13 ,14 },
59
+ {15 ,16 ,17 }}};
60
60
61
61
EXPECT_EQ (c.layout (), xt::layout_type::column_major);
62
62
EXPECT_EQ (c.dimension (),3 );
63
63
EXPECT_EQ (c (0 ,0 ,1 ),1 );
64
64
EXPECT_EQ (c.shape ()[0 ],2 );
65
65
66
66
pyarray<int , xt::layout_type::dynamic> d
67
- {{{0 ,1 ,2 },
68
- {3 ,4 ,5 },
69
- {6 ,7 ,8 }},
70
- {{9 ,10 ,11 },
71
- {12 ,13 ,14 },
72
- {15 ,16 ,17 }}};
67
+ {{{0 ,1 ,2 },
68
+ {3 ,4 ,5 },
69
+ {6 ,7 ,8 }},
70
+ {{9 ,10 ,11 },
71
+ {12 ,13 ,14 },
72
+ {15 ,16 ,17 }}};
73
73
74
74
EXPECT_EQ (d.layout (), xt::layout_type::row_major);
75
75
EXPECT_EQ (d.dimension (),3 );
76
76
EXPECT_EQ (d (0 ,0 ,1 ),1 );
77
77
EXPECT_EQ (d.shape ()[0 ],2 );
78
78
}
79
79
80
+ TEST (pyarray, expression)
81
+ {
82
+ pyarray<int > a = xt::empty<int >({});
83
+
84
+ EXPECT_EQ (a.layout (), xt::layout_type::row_major);
85
+ EXPECT_EQ (a.dimension (),0 );
86
+ EXPECT_EQ (a.size (),1 );
87
+
88
+ pyarray<int > b = xt::empty<int >({5 });
89
+
90
+ EXPECT_EQ (b.layout (), xt::layout_type::row_major);
91
+ EXPECT_EQ (b.dimension (),1 );
92
+ EXPECT_EQ (b.size (),5 );
93
+
94
+ pyarray<int > c = xt::empty<int >({5 ,3 });
95
+
96
+ EXPECT_EQ (c.layout (), xt::layout_type::row_major);
97
+ EXPECT_EQ (c.dimension (),2 );
98
+ EXPECT_EQ (c.size (),15 );
99
+ EXPECT_EQ (c.shape (0 ),5 );
100
+ EXPECT_EQ (c.shape (1 ),3 );
101
+ }
102
+
80
103
TEST (pyarray, shaped_constructor)
81
104
{
82
105
{
@@ -86,7 +109,7 @@ namespace xt
86
109
compare_shape (ra, rm);
87
110
EXPECT_EQ (layout_type::row_major, ra.layout ());
88
111
}
89
-
112
+
90
113
{
91
114
SCOPED_TRACE (" column_major constructor" );
92
115
column_major_result<> cm;
@@ -150,7 +173,7 @@ namespace xt
150
173
central_major_result<> res;
151
174
int value =2 ;
152
175
pyarray<int >a (res.m_shape , res.m_strides , value);
153
-
176
+
154
177
{
155
178
SCOPED_TRACE (" copy constructor" );
156
179
pyarray<int >b (a);
@@ -277,7 +300,7 @@ namespace xt
277
300
EXPECT_EQ (2 ,a1 (1 ));
278
301
EXPECT_EQ (4 ,a2 (1 ,1 ));
279
302
}
280
-
303
+
281
304
TEST (pyarray, zerod)
282
305
{
283
306
pyarray<int > a;