Skip to content

Commit 6fb1197

Browse files
Merge pull request #41 from SylvainCorlay/pytensor-fixes
Fixes for pytensor
2 parents 32e1109 + 86e46e1 commit 6fb1197

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

include/xtensor-python/pycontainer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ namespace xt
295295
template <class D>
296296
inline void pycontainer<D>::reshape(const shape_type& shape, layout l)
297297
{
298-
strides_type strides(shape.size());
298+
strides_type strides = make_sequence<strides_type>(shape.size(), size_type(1));
299299
compute_strides(shape, l, strides);
300300
reshape(shape, strides);
301301
}

include/xtensor-python/pytensor.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace xt
7272
struct xcontainer_inner_types<pytensor<T, N>>
7373
{
7474
using container_type = pybuffer_adaptor<T>;
75-
using shape_type = std::array<npy_int, N>;
75+
using shape_type = std::array<npy_intp, N>;
7676
using strides_type = shape_type;
7777
using backstrides_type = shape_type;
7878
using inner_shape_type = shape_type;
@@ -132,12 +132,12 @@ namespace xt
132132
void init_from_python();
133133
void compute_backstrides();
134134

135-
const inner_shape_type& shape_impl() const;
136-
const inner_strides_type& strides_impl() const;
137-
const backstrides_type& backstrides_impl() const;
135+
const inner_shape_type& shape_impl() const noexcept;
136+
const inner_strides_type& strides_impl() const noexcept;
137+
const backstrides_type& backstrides_impl() const noexcept;
138138

139-
container_type& data_impl();
140-
const container_type& data_impl() const;
139+
container_type& data_impl() noexcept;
140+
const container_type& data_impl() const noexcept;
141141

142142
friend class pycontainer<pytensor<T, N>>;
143143
};
@@ -226,9 +226,9 @@ namespace xt
226226
flags |= NPY_ARRAY_WRITEABLE;
227227
}
228228
int type_num = detail::numpy_traits<T>::type_num;
229-
229+
230230
auto tmp = pybind11::reinterpret_steal<pybind11::object>(
231-
PyArray_New(&PyArray_Type, N, reinterpret_cast<npy_intp*>(shape.data()),
231+
PyArray_New(&PyArray_Type, N, const_cast<npy_intp*>(shape.data()),
232232
type_num, python_strides, nullptr, sizeof(T), flags, nullptr)
233233
);
234234

@@ -274,31 +274,31 @@ namespace xt
274274
}
275275

276276
template <class T, std::size_t N>
277-
inline auto pytensor<T, N>::shape_impl() const -> const inner_shape_type&
277+
inline auto pytensor<T, N>::shape_impl() const noexcept -> const inner_shape_type&
278278
{
279279
return m_shape;
280280
}
281281

282282
template <class T, std::size_t N>
283-
inline auto pytensor<T, N>::strides_impl() const -> const inner_strides_type&
283+
inline auto pytensor<T, N>::strides_impl() const noexcept -> const inner_strides_type&
284284
{
285285
return m_strides;
286286
}
287287

288288
template <class T, std::size_t N>
289-
inline auto pytensor<T, N>::backstrides_impl() const -> const backstrides_type&
289+
inline auto pytensor<T, N>::backstrides_impl() const noexcept -> const backstrides_type&
290290
{
291291
return m_backstrides;
292292
}
293293

294294
template <class T, std::size_t N>
295-
inline auto pytensor<T, N>::data_impl() -> container_type&
295+
inline auto pytensor<T, N>::data_impl() noexcept -> container_type&
296296
{
297297
return m_data;
298298
}
299299

300300
template <class T, std::size_t N>
301-
inline auto pytensor<T, N>::data_impl() const -> const container_type&
301+
inline auto pytensor<T, N>::data_impl() const noexcept -> const container_type&
302302
{
303303
return m_data;
304304
}

0 commit comments

Comments
 (0)