@@ -108,6 +108,7 @@ namespace xt
108108 using semantic_base = xcontainer_semantic<self_type>;
109109 using base_type = pycontainer<self_type>;
110110 using container_type = typename base_type::container_type;
111+ using value_type = typename base_type::value_type;
111112 using pointer = typename base_type::pointer;
112113 using size_type = typename base_type::size_type;
113114 using shape_type = typename base_type::shape_type;
@@ -117,6 +118,12 @@ namespace xt
117118 using inner_strides_type = typename base_type::inner_strides_type;
118119
119120 pyarray () = default ;
121+ pyarray (const value_type& t);
122+ pyarray (nested_initializer_list_t <T, 1 > t);
123+ pyarray (nested_initializer_list_t <T, 2 > t);
124+ pyarray (nested_initializer_list_t <T, 3 > t);
125+ pyarray (nested_initializer_list_t <T, 4 > t);
126+ pyarray (nested_initializer_list_t <T, 5 > t);
120127
121128 pyarray (pybind11::handle h, pybind11::object::borrowed_t );
122129 pyarray (pybind11::handle h, pybind11::object::stolen_t );
@@ -179,6 +186,48 @@ namespace xt
179186 * pyarray implementation *
180187 **************************/
181188
189+ template <class T >
190+ inline pyarray<T>::pyarray(const value_type& t)
191+ {
192+ base_type::reshape (xt::shape<shape_type>(t), layout::row_major);
193+ nested_copy (m_data.begin (), t);
194+ }
195+
196+ template <class T >
197+ inline pyarray<T>::pyarray(nested_initializer_list_t <T, 1 > t)
198+ {
199+ base_type::reshape (xt::shape<shape_type>(t), layout::row_major);
200+ nested_copy (m_data.begin (), t);
201+ }
202+
203+ template <class T >
204+ inline pyarray<T>::pyarray(nested_initializer_list_t <T, 2 > t)
205+ {
206+ base_type::reshape (xt::shape<shape_type>(t), layout::row_major);
207+ nested_copy (m_data.begin (), t);
208+ }
209+
210+ template <class T >
211+ inline pyarray<T>::pyarray(nested_initializer_list_t <T, 3 > t)
212+ {
213+ base_type::reshape (xt::shape<shape_type>(t), layout::row_major);
214+ nested_copy (m_data.begin (), t);
215+ }
216+
217+ template <class T >
218+ inline pyarray<T>::pyarray(nested_initializer_list_t <T, 4 > t)
219+ {
220+ base_type::reshape (xt::shape<shape_type>(t), layout::row_major);
221+ nested_copy (m_data.begin (), t);
222+ }
223+
224+ template <class T >
225+ inline pyarray<T>::pyarray(nested_initializer_list_t <T, 5 > t)
226+ {
227+ base_type::reshape (xt::shape<shape_type>(t), layout::row_major);
228+ nested_copy (m_data.begin (), t);
229+ }
230+
182231 template <class T >
183232 inline pyarray<T>::pyarray(pybind11::handle h, pybind11::object::borrowed_t )
184233 : base_type(h, pybind11::object::borrowed)
0 commit comments