Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ install:
- conda update -q conda
- conda info -a
- conda install gtest cmake -c conda-forge
- conda install xtensor==0.10.9 pytest numpy pybind11==2.1.1 -c conda-forge
- conda install xtensor==0.11.0 pytest numpy pybind11==2.1.1 -c conda-forge
- "set PYTHONHOME=%MINICONDA%"
- cmake -G "NMake Makefiles" -D CMAKE_INSTALL_PREFIX=%MINICONDA%\\Library -D BUILD_TESTS=ON -D PYTHON_EXECUTABLE=%MINICONDA%\\python.exe .
- nmake test_xtensor_python
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ install:
- conda update -q conda
# Useful for debugging any issues with conda
- conda info -a
- conda install xtensor==0.10.9 pytest numpy pybind11==2.1.1 -c conda-forge
- conda install xtensor==0.11.0 pytest numpy pybind11==2.1.1 -c conda-forge
- conda install cmake gtest -c conda-forge
- cmake -D BUILD_TESTS=ON -D CMAKE_INSTALL_PREFIX=$HOME/miniconda .
- make -j2 test_xtensor_python
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ from the `docs` subdirectory.

| `xtensor-python` | `xtensor` | `pybind11` |
|-------------------|------------|-------------|
| master | ^0.10.9 | ^2.1.0 |
| master | ^0.11.0 | ^2.1.0 |
| 0.12.x | ^0.10.2 | 2.1.\* |
| 0.11.x | ^0.10.0 | 2.1.\* |
| 0.10.x | ^0.9.0 | 2.1.\* |
Expand Down
4 changes: 2 additions & 2 deletions include/xtensor-python/pyarray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,13 @@ namespace xt
template <class A>
inline auto pyarray_backstrides<A>::cbegin() const -> const_iterator
{
const_iterator(this, 0);
return const_iterator(this, 0);
}

template <class A>
inline auto pyarray_backstrides<A>::cend() const -> const_iterator
{
const_iterator(this, size());
return const_iterator(this, size());
}

/**************************
Expand Down
36 changes: 33 additions & 3 deletions include/xtensor-python/pystrides_adaptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace xt
using difference_type = std::ptrdiff_t;

using const_iterator = pystrides_iterator<N>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;

pystrides_adaptor() = default;
pystrides_adaptor(const_pointer data, size_type size);
Expand All @@ -51,6 +52,11 @@ namespace xt
const_iterator cbegin() const;
const_iterator cend() const;

const_reverse_iterator rbegin() const;
const_reverse_iterator rend() const;
const_reverse_iterator crbegin() const;
const_reverse_iterator crend() const;

private:

const_pointer p_data;
Expand Down Expand Up @@ -114,6 +120,7 @@ namespace xt
++p_current;
return tmp;
}

inline self_type operator--(int)
{
self_type tmp(*this);
Expand Down Expand Up @@ -143,11 +150,10 @@ namespace xt
return self_type(p_current - n);
}

inline self_type operator-(const self_type& rhs) const
inline difference_type operator-(const self_type& rhs) const
{
self_type tmp(*this);
tmp -= (p_current - rhs.p_current);
return tmp;
return p_current - rhs.p_current;
}

pointer get_pointer() const { return p_current; }
Expand Down Expand Up @@ -262,6 +268,30 @@ namespace xt
{
return const_iterator(p_data + m_size);
}

template <std::size_t N>
inline auto pystrides_adaptor<N>::rbegin() const -> const_reverse_iterator
{
return crbegin();
}

template <std::size_t N>
inline auto pystrides_adaptor<N>::rend() const -> const_reverse_iterator
{
return crend();
}

template <std::size_t N>
inline auto pystrides_adaptor<N>::crbegin() const -> const_reverse_iterator
{
return const_reverse_iterator(cend());
}

template <std::size_t N>
inline auto pystrides_adaptor<N>::crend() const -> const_reverse_iterator
{
return const_reverse_iterator(cbegin());
}
}

#endif
Loading