@@ -71,8 +71,7 @@ namespace xt
7171 };
7272
7373 template <class T , std::size_t N>
74- class pytensor : public pybind11 ::object,
75- public pycontainer<pytensor<T, N>>,
74+ class pytensor : public pycontainer <pytensor<T, N>>,
7675 public xcontainer_semantic<pytensor<T, N>>
7776 {
7877
@@ -88,7 +87,7 @@ namespace xt
8887 using strides_type = typename base_type::strides_type;
8988 using backstrides_type = typename base_type::backstrides_type;
9089
91- pytensor ();
90+ pytensor () = default ;
9291
9392 pytensor (pybind11::handle h, borrowed_t );
9493 pytensor (pybind11::handle h, stolen_t );
@@ -137,30 +136,24 @@ namespace xt
137136 * pytensor implementation *
138137 ***************************/
139138
140- template <class T , std::size_t N>
141- inline pytensor<T, N>::pytensor()
142- {
143- }
144-
145139 template <class T , std::size_t N>
146140 inline pytensor<T, N>::pytensor(pybind11::handle h, borrowed_t )
147- : pybind11::object (h, borrowed)
141+ : base_type (h, borrowed)
148142 {
149143 init_from_python ();
150144 }
151145
152146 template <class T , std::size_t N>
153147 inline pytensor<T, N>::pytensor(pybind11::handle h, stolen_t )
154- : pybind11::object (h, stolen)
148+ : base_type (h, stolen)
155149 {
156150 init_from_python ();
157151 }
158152
159153 template <class T , std::size_t N>
160154 inline pytensor<T, N>::pytensor(const pybind11::object& o)
161- : pybind11::object (base_type::raw_array_t (o.ptr()), stolen)
155+ : base_type (base_type::raw_array_t (o.ptr()), stolen)
162156 {
163- // std::cout << "Object constructor" << std::endl;
164157 if (!this ->m_ptr )
165158 throw pybind11::error_already_set ();
166159 init_from_python ();
@@ -170,14 +163,12 @@ namespace xt
170163 inline pytensor<T, N>::pytensor(const shape_type& shape,
171164 const strides_type& strides)
172165 {
173- // std::cout << "Shape + strides constructor" << std::endl;
174166 init_tensor (shape, strides);
175167 }
176168
177169 template <class T , std::size_t N>
178170 inline pytensor<T, N>::pytensor(const shape_type& shape)
179171 {
180- // std::cout << "Shape constructor" << std::endl;
181172 base_type::fill_default_strides (shape, m_strides);
182173 init_tensor (shape, m_strides);
183174 }
@@ -186,7 +177,6 @@ namespace xt
186177 template <class E >
187178 inline pytensor<T, N>::pytensor(const xexpression<E>& e)
188179 {
189- // std::cout << "Extended constructor" << std::endl;
190180 semantic_base::assign (e);
191181 }
192182
@@ -200,7 +190,6 @@ namespace xt
200190 template <class T , std::size_t N>
201191 inline void pytensor<T, N>::reshape(const shape_type& shape)
202192 {
203- // std::cout << "Reshape(shape)" << std::endl;
204193 if (shape != m_shape)
205194 {
206195 strides_type strides;
@@ -212,17 +201,14 @@ namespace xt
212201 template <class T , std::size_t N>
213202 inline void pytensor<T, N>::reshape(const shape_type& shape, const strides_type& strides)
214203 {
215- // std::cout << "Reshape(shape, strides)" << std::endl;
216204 self_type tmp (shape, strides);
217205 *this = std::move (tmp);
218206 }
219207
220208 template <class T , std::size_t N>
221209 inline auto pytensor<T, N>::ensure(pybind11::handle h) -> self_type
222210 {
223- // std::cout << "Ensure" << std::endl;
224211 auto result = pybind11::reinterpret_steal<self_type>(base_type::raw_array_t (h.ptr ()));
225- // auto result = pybind11::reinterpret_steal<self_type>(h.ptr());
226212 if (result.ptr () == nullptr )
227213 PyErr_Clear ();
228214 return result;
@@ -238,7 +224,6 @@ namespace xt
238224 template <class T , std::size_t N>
239225 inline void pytensor<T, N>::init_tensor(const shape_type& shape, const strides_type& strides)
240226 {
241- // std::cout << "init tensor" << std::endl;
242227 npy_intp python_strides[N];
243228 std::transform (strides.beign (), strides.end (), python_strides,
244229 [](auto v) { return sizeof (T) * v; });
@@ -266,7 +251,6 @@ namespace xt
266251 template <class T , std::size_t N>
267252 inline void pytensor<T, N>::init_from_python()
268253 {
269- // std::cout << "init from python" << std::endl;
270254 if (PyArray_NDIM (this ->m_ptr ) != N)
271255 throw std::runtime_error (" NumPy: ndarray has incorrect number of dimensions" );
272256
0 commit comments