Skip to content

Commit 34d65a9

Browse files
committed
Update to use xtensor 0.11
1 parent dbd3a2f commit 34d65a9

File tree

8 files changed

+360
-126
lines changed

8 files changed

+360
-126
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ install:
2323
- conda update -q conda
2424
- conda info -a
2525
- conda install gtest cmake -c conda-forge
26-
- conda install xtensor==0.10.9 pytest numpy pybind11==2.1.1 -c conda-forge
26+
- conda install xtensor==0.11.0 pytest numpy pybind11==2.1.1 -c conda-forge
2727
- "set PYTHONHOME=%MINICONDA%"
2828
- cmake -G "NMake Makefiles" -D CMAKE_INSTALL_PREFIX=%MINICONDA%\\Library -D BUILD_TESTS=ON -D PYTHON_EXECUTABLE=%MINICONDA%\\python.exe .
2929
- nmake test_xtensor_python

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ install:
9595
- conda update -q conda
9696
# Useful for debugging any issues with conda
9797
- conda info -a
98-
- conda install xtensor==0.10.9 pytest numpy pybind11==2.1.1 -c conda-forge
98+
- conda install xtensor==0.11.0 pytest numpy pybind11==2.1.1 -c conda-forge
9999
- conda install cmake gtest -c conda-forge
100100
- cmake -D BUILD_TESTS=ON -D CMAKE_INSTALL_PREFIX=$HOME/miniconda .
101101
- make -j2 test_xtensor_python

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ from the `docs` subdirectory.
189189

190190
| `xtensor-python` | `xtensor` | `pybind11` |
191191
|-------------------|------------|-------------|
192-
| master | ^0.10.9 | ^2.1.0 |
192+
| master | ^0.11.0 | ^2.1.0 |
193193
| 0.12.x | ^0.10.2 | 2.1.\* |
194194
| 0.11.x | ^0.10.0 | 2.1.\* |
195195
| 0.10.x | ^0.9.0 | 2.1.\* |

include/xtensor-python/pyarray.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,13 @@ namespace xt
427427
template <class A>
428428
inline auto pyarray_backstrides<A>::cbegin() const -> const_iterator
429429
{
430-
const_iterator(this, 0);
430+
return const_iterator(this, 0);
431431
}
432432

433433
template <class A>
434434
inline auto pyarray_backstrides<A>::cend() const -> const_iterator
435435
{
436-
const_iterator(this, size());
436+
return const_iterator(this, size());
437437
}
438438

439439
/**************************

include/xtensor-python/pystrides_adaptor.hpp

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ namespace xt
3434
using difference_type = std::ptrdiff_t;
3535

3636
using const_iterator = pystrides_iterator<N>;
37+
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
3738

3839
pystrides_adaptor() = default;
3940
pystrides_adaptor(const_pointer data, size_type size);
@@ -51,6 +52,11 @@ namespace xt
5152
const_iterator cbegin() const;
5253
const_iterator cend() const;
5354

55+
const_reverse_iterator rbegin() const;
56+
const_reverse_iterator rend() const;
57+
const_reverse_iterator crbegin() const;
58+
const_reverse_iterator crend() const;
59+
5460
private:
5561

5662
const_pointer p_data;
@@ -114,6 +120,7 @@ namespace xt
114120
++p_current;
115121
return tmp;
116122
}
123+
117124
inline self_type operator--(int)
118125
{
119126
self_type tmp(*this);
@@ -143,11 +150,10 @@ namespace xt
143150
return self_type(p_current - n);
144151
}
145152

146-
inline self_type operator-(const self_type& rhs) const
153+
inline difference_type operator-(const self_type& rhs) const
147154
{
148155
self_type tmp(*this);
149-
tmp -= (p_current - rhs.p_current);
150-
return tmp;
156+
return p_current - rhs.p_current;
151157
}
152158

153159
pointer get_pointer() const { return p_current; }
@@ -262,6 +268,30 @@ namespace xt
262268
{
263269
return const_iterator(p_data + m_size);
264270
}
271+
272+
template <std::size_t N>
273+
inline auto pystrides_adaptor<N>::rbegin() const -> const_reverse_iterator
274+
{
275+
return crbegin();
276+
}
277+
278+
template <std::size_t N>
279+
inline auto pystrides_adaptor<N>::rend() const -> const_reverse_iterator
280+
{
281+
return crend();
282+
}
283+
284+
template <std::size_t N>
285+
inline auto pystrides_adaptor<N>::crbegin() const -> const_reverse_iterator
286+
{
287+
return const_reverse_iterator(cend());
288+
}
289+
290+
template <std::size_t N>
291+
inline auto pystrides_adaptor<N>::crend() const -> const_reverse_iterator
292+
{
293+
return const_reverse_iterator(cbegin());
294+
}
265295
}
266296

267297
#endif

0 commit comments

Comments
 (0)