Skip to content

Commit 0c46275

Browse files
authored
Merge pull request #147 from JohanMabille/xtensor_0160
update to xtensor 0.16.0
2 parents 73ce49f + c07a8b6 commit 0c46275

File tree

8 files changed

+73
-73
lines changed

8 files changed

+73
-73
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ install:
2424
- conda info -a
2525
- conda install gtest cmake -c conda-forge
2626
- conda install pytest numpy pybind11==2.2.1 -c conda-forge
27-
- conda install xtensor==0.15.8 -c QuantStack
27+
- conda install xtensor==0.16.0 -c QuantStack
2828
- "set PYTHONHOME=%MINICONDA%"
2929
- cmake -G "NMake Makefiles" -D CMAKE_INSTALL_PREFIX=%MINICONDA%\\Library -D BUILD_TESTS=ON -D PYTHON_EXECUTABLE=%MINICONDA%\\python.exe .
3030
- nmake test_xtensor_python

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ install:
9797
- conda info -a
9898
- conda install pytest numpy pybind11==2.2.1 -c conda-forge
9999
- conda install cmake gtest -c conda-forge
100-
- conda install xtensor==0.15.8 -c QuantStack
100+
- conda install xtensor==0.16.0 -c QuantStack
101101
- cmake -D BUILD_TESTS=ON -D CMAKE_INSTALL_PREFIX=$HOME/miniconda .
102102
- make -j2 test_xtensor_python
103103
- make install

include/xtensor-python/pyarray.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ namespace xt
291291
template <class T>
292292
struct xcontainer_inner_types<pyarray<T>>
293293
{
294-
using container_type = xbuffer_adaptor<T*>;
295-
using shape_type = std::vector<typename container_type::size_type>;
294+
using storage_type = xbuffer_adaptor<T*>;
295+
using shape_type = std::vector<typename storage_type::size_type>;
296296
using strides_type = shape_type;
297297
using backstrides_type = pyarray_backstrides<pyarray<T>>;
298298
using inner_shape_type = xbuffer_adaptor<std::size_t*>;
@@ -321,7 +321,7 @@ namespace xt
321321
using self_type = pyarray<T>;
322322
using semantic_base = xcontainer_semantic<self_type>;
323323
using base_type = pycontainer<self_type>;
324-
using container_type = typename base_type::container_type;
324+
using storage_type = typename base_type::storage_type;
325325
using value_type = typename base_type::value_type;
326326
using reference = typename base_type::reference;
327327
using const_reference = typename base_type::const_reference;
@@ -374,7 +374,7 @@ namespace xt
374374
inner_shape_type m_shape;
375375
inner_strides_type m_strides;
376376
mutable inner_backstrides_type m_backstrides;
377-
container_type m_data;
377+
storage_type m_data;
378378

379379
void init_array(const shape_type& shape, const strides_type& strides);
380380
void init_from_python();
@@ -383,8 +383,8 @@ namespace xt
383383
const inner_strides_type& strides_impl() const noexcept;
384384
const inner_backstrides_type& backstrides_impl() const noexcept;
385385

386-
container_type& data_impl() noexcept;
387-
const container_type& data_impl() const noexcept;
386+
storage_type& storage_impl() noexcept;
387+
const storage_type& storage_impl() const noexcept;
388388

389389
friend class xcontainer<pyarray<T>>;
390390
friend class pycontainer<pyarray<T>>;
@@ -633,7 +633,7 @@ namespace xt
633633

634634
this->m_ptr = tmp.release().ptr();
635635
init_from_python();
636-
std::copy(rhs.data().cbegin(), rhs.data().cend(), this->data().begin());
636+
std::copy(rhs.storage().cbegin(), rhs.storage().cend(), this->storage().begin());
637637
}
638638

639639
/**
@@ -730,8 +730,8 @@ namespace xt
730730
m_strides = inner_strides_type(reinterpret_cast<size_type*>(PyArray_STRIDES(this->python_array())),
731731
static_cast<size_type>(PyArray_NDIM(this->python_array())));
732732
m_backstrides = backstrides_type(*this);
733-
m_data = container_type(reinterpret_cast<pointer>(PyArray_DATA(this->python_array())),
734-
this->get_min_stride() * static_cast<size_type>(PyArray_SIZE(this->python_array())));
733+
m_data = storage_type(reinterpret_cast<pointer>(PyArray_DATA(this->python_array())),
734+
this->get_min_stride() * static_cast<size_type>(PyArray_SIZE(this->python_array())));
735735
}
736736

737737
template <class T>
@@ -757,13 +757,13 @@ namespace xt
757757
}
758758

759759
template <class T>
760-
inline auto pyarray<T>::data_impl() noexcept -> container_type&
760+
inline auto pyarray<T>::storage_impl() noexcept -> storage_type&
761761
{
762762
return m_data;
763763
}
764764

765765
template <class T>
766-
inline auto pyarray<T>::data_impl() const noexcept -> const container_type&
766+
inline auto pyarray<T>::storage_impl() const noexcept -> const storage_type&
767767
{
768768
return m_data;
769769
}

include/xtensor-python/pycontainer.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ namespace xt
5858

5959
using base_type = xcontainer<D>;
6060
using inner_types = xcontainer_inner_types<D>;
61-
using container_type = typename inner_types::container_type;
62-
using value_type = typename container_type::value_type;
63-
using reference = typename container_type::reference;
64-
using const_reference = typename container_type::const_reference;
65-
using pointer = typename container_type::pointer;
66-
using const_pointer = typename container_type::const_pointer;
67-
using size_type = typename container_type::size_type;
68-
using difference_type = typename container_type::difference_type;
61+
using storage_type = typename inner_types::storage_type;
62+
using value_type = typename storage_type::value_type;
63+
using reference = typename storage_type::reference;
64+
using const_reference = typename storage_type::const_reference;
65+
using pointer = typename storage_type::pointer;
66+
using const_pointer = typename storage_type::const_pointer;
67+
using size_type = typename storage_type::size_type;
68+
using difference_type = typename storage_type::difference_type;
6969

7070
using shape_type = typename inner_types::shape_type;
7171
using strides_type = typename inner_types::strides_type;

include/xtensor-python/pytensor.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ namespace xt
110110
template <class T, std::size_t N>
111111
struct xcontainer_inner_types<pytensor<T, N>>
112112
{
113-
using container_type = xbuffer_adaptor<T*>;
113+
using storage_type = xbuffer_adaptor<T*>;
114114
using shape_type = std::array<npy_intp, N>;
115115
using strides_type = shape_type;
116116
using backstrides_type = shape_type;
@@ -144,7 +144,7 @@ namespace xt
144144
using self_type = pytensor<T, N>;
145145
using semantic_base = xcontainer_semantic<self_type>;
146146
using base_type = pycontainer<self_type>;
147-
using container_type = typename base_type::container_type;
147+
using storage_type = typename base_type::storage_type;
148148
using value_type = typename base_type::value_type;
149149
using reference = typename base_type::reference;
150150
using const_reference = typename base_type::const_reference;
@@ -191,7 +191,7 @@ namespace xt
191191
inner_shape_type m_shape;
192192
inner_strides_type m_strides;
193193
inner_backstrides_type m_backstrides;
194-
container_type m_data;
194+
storage_type m_data;
195195

196196
void init_tensor(const shape_type& shape, const strides_type& strides);
197197
void init_from_python();
@@ -203,8 +203,8 @@ namespace xt
203203
inner_backstrides_type& backstrides_impl() noexcept;
204204
const inner_backstrides_type& backstrides_impl() const noexcept;
205205

206-
container_type& data_impl() noexcept;
207-
const container_type& data_impl() const noexcept;
206+
storage_type& storage_impl() noexcept;
207+
const storage_type& storage_impl() const noexcept;
208208

209209
friend class xcontainer<pytensor<T, N>>;
210210
friend class pycontainer<pytensor<T, N>>;
@@ -334,7 +334,7 @@ namespace xt
334334
: base_type()
335335
{
336336
init_tensor(rhs.shape(), rhs.strides());
337-
std::copy(rhs.data().cbegin(), rhs.data().cend(), this->data().begin());
337+
std::copy(rhs.storage().cbegin(), rhs.storage().cend(), this->storage().begin());
338338
}
339339

340340
/**
@@ -417,8 +417,8 @@ namespace xt
417417
m_shape = shape;
418418
m_strides = strides;
419419
adapt_strides(m_shape, m_strides, m_backstrides);
420-
m_data = container_type(reinterpret_cast<pointer>(PyArray_DATA(this->python_array())),
421-
static_cast<size_type>(PyArray_SIZE(this->python_array())));
420+
m_data = storage_type(reinterpret_cast<pointer>(PyArray_DATA(this->python_array())),
421+
static_cast<size_type>(PyArray_SIZE(this->python_array())));
422422
}
423423

424424
template <class T, std::size_t N>
@@ -433,8 +433,8 @@ namespace xt
433433
std::transform(PyArray_STRIDES(this->python_array()), PyArray_STRIDES(this->python_array()) + N, m_strides.begin(),
434434
[](auto v) { return v / sizeof(T); });
435435
adapt_strides(m_shape, m_strides, m_backstrides);
436-
m_data = container_type(reinterpret_cast<pointer>(PyArray_DATA(this->python_array())),
437-
this->get_min_stride() * static_cast<size_type>(PyArray_SIZE(this->python_array())));
436+
m_data = storage_type(reinterpret_cast<pointer>(PyArray_DATA(this->python_array())),
437+
this->get_min_stride() * static_cast<size_type>(PyArray_SIZE(this->python_array())));
438438
}
439439

440440
template <class T, std::size_t N>
@@ -474,13 +474,13 @@ namespace xt
474474
}
475475

476476
template <class T, std::size_t N>
477-
inline auto pytensor<T, N>::data_impl() noexcept -> container_type&
477+
inline auto pytensor<T, N>::storage_impl() noexcept -> storage_type&
478478
{
479479
return m_data;
480480
}
481481

482482
template <class T, std::size_t N>
483-
inline auto pytensor<T, N>::data_impl() const noexcept -> const container_type&
483+
inline auto pytensor<T, N>::storage_impl() const noexcept -> const storage_type&
484484
{
485485
return m_data;
486486
}

test/test_common.hpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,15 @@ namespace xt
234234
vec.resize(rm.shape(), layout_type::row_major);
235235

236236
assign_array(vec, rm.m_assigner);
237-
EXPECT_TRUE(std::equal(vec.data().cbegin(), vec.data().cend(), rm.m_data.cbegin()));
237+
EXPECT_TRUE(std::equal(vec.storage().cbegin(), vec.storage().cend(), rm.m_data.cbegin()));
238238

239239
auto vec_copy = vec;
240240

241241
shape_type shape_new(rm.shape());
242242
auto vt = transpose(vec);
243243
std::reverse(shape_new.begin(), shape_new.end());
244244
EXPECT_EQ(vt.shape(), shape_new);
245-
EXPECT_TRUE(std::equal(vt.data().cbegin(), vt.data().cend(), rm.m_data.cbegin()));
245+
EXPECT_TRUE(std::equal(vt.storage().cbegin(), vt.storage().cend(), rm.m_data.cbegin()));
246246

247247
strides_type new_strides = {rm.m_strides[2],
248248
rm.m_strides[1],
@@ -266,7 +266,7 @@ namespace xt
266266
vec.resize(rm.shape(), layout_type::row_major);
267267

268268
assign_array(vec, rm.m_assigner);
269-
EXPECT_TRUE(std::equal(vec.data().cbegin(), vec.data().cend(), rm.m_data.cbegin()));
269+
EXPECT_TRUE(std::equal(vec.storage().cbegin(), vec.storage().cend(), rm.m_data.cbegin()));
270270

271271
auto vec_copy = vec;
272272

@@ -275,7 +275,7 @@ namespace xt
275275
auto vt = transpose(vec, {1, 0, 2});
276276
shape_type shape_new = {a[1], a[0], a[2]};
277277
EXPECT_TRUE(std::equal(vt.shape().cbegin(), vt.shape().cend(), shape_new.begin()));
278-
EXPECT_TRUE(std::equal(vt.data().cbegin(), vt.data().cend(), rm.m_data.cbegin()));
278+
EXPECT_TRUE(std::equal(vt.storage().cbegin(), vt.storage().cend(), rm.m_data.cbegin()));
279279

280280
strides_type new_strides = {rm.m_strides[1],
281281
rm.m_strides[0],
@@ -342,7 +342,7 @@ namespace xt
342342
row_major_result<C> rm;
343343
vec.resize(rm.m_shape, layout_type::row_major);
344344
assign_array(vec, rm.m_assigner);
345-
EXPECT_TRUE(std::equal(vec.data().cbegin(), vec.data().cend(), rm.m_data.cbegin()));
345+
EXPECT_TRUE(std::equal(vec.storage().cbegin(), vec.storage().cend(), rm.m_data.cbegin()));
346346
EXPECT_EQ(vec(0, 1, 1), vec(1, 1));
347347
EXPECT_EQ(vec(2, 1, 3), vec(2, 2, 2, 1, 3));
348348
test_bound_check(vec);
@@ -353,7 +353,7 @@ namespace xt
353353
column_major_result<C> cm;
354354
vec.resize(cm.m_shape, layout_type::column_major);
355355
assign_array(vec, cm.m_assigner);
356-
EXPECT_TRUE(std::equal(vec.data().cbegin(), vec.data().cend(), cm.m_data.cbegin()));
356+
EXPECT_TRUE(std::equal(vec.storage().cbegin(), vec.storage().cend(), cm.m_data.cbegin()));
357357
EXPECT_EQ(vec(0, 1, 1), vec(1, 1));
358358
EXPECT_EQ(vec(2, 1, 3), vec(2, 2, 2, 1, 3));
359359
test_bound_check(vec);
@@ -364,7 +364,7 @@ namespace xt
364364
central_major_result<C> cem;
365365
vec.resize(cem.m_shape, cem.m_strides);
366366
assign_array(vec, cem.m_assigner);
367-
EXPECT_TRUE(std::equal(vec.data().cbegin(), vec.data().cend(), cem.m_data.cbegin()));
367+
EXPECT_TRUE(std::equal(vec.storage().cbegin(), vec.storage().cend(), cem.m_data.cbegin()));
368368
EXPECT_EQ(vec(0, 1, 1), vec(1, 1));
369369
EXPECT_EQ(vec(2, 1, 3), vec(2, 2, 2, 1, 3));
370370
test_bound_check(vec);
@@ -375,7 +375,7 @@ namespace xt
375375
unit_shape_result<C> usr;
376376
vec.resize(usr.m_shape, layout_type::row_major);
377377
assign_array(vec, usr.m_assigner);
378-
EXPECT_TRUE(std::equal(vec.data().cbegin(), vec.data().cend(), usr.m_data.cbegin()));
378+
EXPECT_TRUE(std::equal(vec.storage().cbegin(), vec.storage().cend(), usr.m_data.cbegin()));
379379
EXPECT_EQ(vec(0, 1, 0), vec(1, 0));
380380
EXPECT_EQ(vec(2, 0, 3), vec(2, 2, 2, 0, 3));
381381
test_bound_check(vec);
@@ -475,7 +475,7 @@ namespace xt
475475
row_major_result<C> rm;
476476
vec.resize(rm.m_shape, layout_type::row_major);
477477
indexed_assign_array(vec, rm.m_assigner);
478-
EXPECT_TRUE(std::equal(vec.data().cbegin(), vec.data().cend(), rm.m_data.cbegin()));
478+
EXPECT_TRUE(std::equal(vec.storage().cbegin(), vec.storage().cend(), rm.m_data.cbegin()));
479479
EXPECT_EQ(vec(0, 1, 1), vec[index1]);
480480
EXPECT_EQ(vec(2, 1, 3), vec[index2]);
481481
}
@@ -485,7 +485,7 @@ namespace xt
485485
column_major_result<C> cm;
486486
vec.resize(cm.m_shape, layout_type::column_major);
487487
indexed_assign_array(vec, cm.m_assigner);
488-
EXPECT_TRUE(std::equal(vec.data().cbegin(), vec.data().cend(), cm.m_data.cbegin()));
488+
EXPECT_TRUE(std::equal(vec.storage().cbegin(), vec.storage().cend(), cm.m_data.cbegin()));
489489
EXPECT_EQ(vec(0, 1, 1), vec[index1]);
490490
EXPECT_EQ(vec(2, 1, 3), vec[index2]);
491491
}
@@ -495,7 +495,7 @@ namespace xt
495495
central_major_result<C> cem;
496496
vec.resize(cem.m_shape, cem.m_strides);
497497
indexed_assign_array(vec, cem.m_assigner);
498-
EXPECT_TRUE(std::equal(vec.data().cbegin(), vec.data().cend(), cem.m_data.cbegin()));
498+
EXPECT_TRUE(std::equal(vec.storage().cbegin(), vec.storage().cend(), cem.m_data.cbegin()));
499499
EXPECT_EQ(vec(0, 1, 1), vec[index1]);
500500
EXPECT_EQ(vec(2, 1, 3), vec[index2]);
501501
}
@@ -505,7 +505,7 @@ namespace xt
505505
unit_shape_result<C> usr;
506506
vec.resize(usr.m_shape, layout_type::row_major);
507507
indexed_assign_array(vec, usr.m_assigner);
508-
EXPECT_TRUE(std::equal(vec.data().cbegin(), vec.data().cend(), usr.m_data.cbegin()));
508+
EXPECT_TRUE(std::equal(vec.storage().cbegin(), vec.storage().cend(), usr.m_data.cbegin()));
509509
xindex id1 = {1, 0};
510510
xindex id2 = {2, 2, 2, 0, 3};
511511
EXPECT_EQ(vec(0, 1, 0), vec[id1]);
@@ -580,7 +580,7 @@ namespace xt
580580
row_major_result<C> rm;
581581
vecrm.resize(rm.m_shape, layout_type::row_major);
582582
std::copy(rm.data().cbegin(), rm.data().cend(), vecrm.template begin<layout_type::row_major>());
583-
EXPECT_TRUE(std::equal(rm.data().cbegin(), rm.data().cend(), vecrm.data().cbegin()));
583+
EXPECT_TRUE(std::equal(rm.data().cbegin(), rm.data().cend(), vecrm.storage().cbegin()));
584584
//EXPECT_EQ(vecrm.template end<layout_type::row_major>(), vecrm.data().end());
585585
}
586586

@@ -589,7 +589,7 @@ namespace xt
589589
column_major_result<C> cm;
590590
veccm.resize(cm.m_shape, layout_type::column_major);
591591
std::copy(cm.data().cbegin(), cm.data().cend(), veccm.template begin<layout_type::column_major>());
592-
EXPECT_TRUE(std::equal(cm.data().cbegin(), cm.data().cend(), veccm.data().cbegin()));
592+
EXPECT_TRUE(std::equal(cm.data().cbegin(), cm.data().cend(), veccm.storage().cbegin()));
593593
//EXPECT_EQ(veccm.template end<layout_type::column_major>(), veccm.data().end());
594594
}
595595
}

0 commit comments

Comments
 (0)