99#ifndef PY_ARRAY_HPP
1010#define PY_ARRAY_HPP
1111
12+ #include < algorithm>
1213#include < cstddef>
1314#include < vector>
14- #include < algorithm>
1515
16- #include " xtensor/xsemantic.hpp"
17- #include " xtensor/xiterator.hpp"
1816#include " xtensor/xbuffer_adaptor.hpp"
17+ #include " xtensor/xiterator.hpp"
18+ #include " xtensor/xsemantic.hpp"
1919
2020#include " pycontainer.hpp"
2121#include " pystrides_adaptor.hpp"
@@ -62,7 +62,7 @@ namespace pybind11
6262 return static_cast <bool >(value);
6363 }
6464
65- static handle cast (const handle & src, return_value_policy, handle)
65+ static handle cast (const handle& src, return_value_policy, handle)
6666 {
6767 return src.inc_ref ();
6868 }
@@ -135,9 +135,9 @@ namespace xt
135135 using semantic_base = xcontainer_semantic<self_type>;
136136 using base_type = pycontainer<self_type>;
137137 using container_type = typename base_type::container_type;
138- using value_type = typename base_type::value_type;
139- using reference = typename base_type::reference;
140- using const_reference = typename base_type::const_reference;
138+ using value_type = typename base_type::value_type;
139+ using reference = typename base_type::reference;
140+ using const_reference = typename base_type::const_reference;
141141 using pointer = typename base_type::pointer;
142142 using size_type = typename base_type::size_type;
143143 using shape_type = typename base_type::shape_type;
@@ -157,8 +157,8 @@ namespace xt
157157
158158 pyarray (pybind11::handle h, pybind11::object::borrowed_t );
159159 pyarray (pybind11::handle h, pybind11::object::stolen_t );
160- pyarray (const pybind11::object & o);
161-
160+ pyarray (const pybind11::object& o);
161+
162162 explicit pyarray (const shape_type& shape, layout_type l = layout_type::row_major);
163163 explicit pyarray (const shape_type& shape, const_reference value, layout_type l = layout_type::row_major);
164164 explicit pyarray (const shape_type& shape, const strides_type& strides, const_reference value);
@@ -201,7 +201,7 @@ namespace xt
201201
202202 friend class xcontainer <pyarray<T>>;
203203 };
204-
204+
205205 /* *************************************
206206 * pyarray_backstrides implementation *
207207 **************************************/
@@ -223,7 +223,7 @@ namespace xt
223223 {
224224 value_type sh = p_a->shape ()[i];
225225 value_type res = sh == 1 ? 0 : (sh - 1 ) * p_a->strides ()[i];
226- return res;
226+ return res;
227227 }
228228
229229 /* *************************
@@ -311,7 +311,7 @@ namespace xt
311311 }
312312
313313 template <class T >
314- inline pyarray<T>::pyarray(const pybind11::object & o)
314+ inline pyarray<T>::pyarray(const pybind11::object& o)
315315 : base_type(o)
316316 {
317317 init_from_python ();
@@ -348,7 +348,7 @@ namespace xt
348348 init_array (shape, strides);
349349 std::fill (m_data.begin (), m_data.end (), value);
350350 }
351-
351+
352352 /* *
353353 * Allocates an uninitialized pyarray with the specified shape and strides.
354354 * Elements are initialized to the specified value.
@@ -389,8 +389,7 @@ namespace xt
389389 : base_type()
390390 {
391391 auto tmp = pybind11::reinterpret_steal<pybind11::object>(
392- PyArray_NewLikeArray (rhs.python_array (), NPY_KEEPORDER, nullptr , 1 )
393- );
392+ PyArray_NewLikeArray (rhs.python_array (), NPY_KEEPORDER, nullptr , 1 ));
394393
395394 if (!tmp)
396395 {
@@ -464,22 +463,21 @@ namespace xt
464463 strides_type adapted_strides (strides);
465464
466465 std::transform (strides.begin (), strides.end (), adapted_strides.begin (),
467- [](auto v) { return sizeof (T) * v; });
466+ [](auto v) { return sizeof (T) * v; });
468467
469468 int flags = NPY_ARRAY_ALIGNED;
470469 if (!std::is_const<T>::value)
471470 {
472471 flags |= NPY_ARRAY_WRITEABLE;
473472 }
474473 int type_num = detail::numpy_traits<T>::type_num;
475-
474+
476475 npy_intp* shape_data = reinterpret_cast <npy_intp*>(const_cast <size_type*>(shape.data ()));
477476 npy_intp* strides_data = reinterpret_cast <npy_intp*>(adapted_strides.data ());
478477 auto tmp = pybind11::reinterpret_steal<pybind11::object>(
479- PyArray_New (&PyArray_Type, static_cast <int >(shape.size ()), shape_data, type_num, strides_data,
480- nullptr , static_cast <int >(sizeof (T)), flags, nullptr )
481- );
482-
478+ PyArray_New (&PyArray_Type, static_cast <int >(shape.size ()), shape_data, type_num, strides_data,
479+ nullptr , static_cast <int >(sizeof (T)), flags, nullptr ));
480+
483481 if (!tmp)
484482 {
485483 throw std::runtime_error (" NumPy: unable to create ndarray" );
@@ -537,5 +535,3 @@ namespace xt
537535}
538536
539537#endif
540-
541-
0 commit comments