Skip to content

Commit 2a90335

Browse files
Merge pull request #97 from SylvainCorlay/xbuffer-adaptor
Use xbuffer_adaptor
2 parents 09eaf4a + 9eb21db commit 2a90335

File tree

12 files changed

+255
-493
lines changed

12 files changed

+255
-493
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.0 pytest numpy pybind11==2.1.1 -c conda-forge
26+
- conda install xtensor==0.10.2 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
@@ -94,7 +94,7 @@ install:
9494
- conda update -q conda
9595
# Useful for debugging any issues with conda
9696
- conda info -a
97-
- conda install xtensor==0.10.0 pytest numpy pybind11==2.1.1 -c conda-forge
97+
- conda install xtensor==0.10.2 pytest numpy pybind11==2.1.1 -c conda-forge
9898
- cd test
9999
- conda env create -f ./test-environment.yml
100100
- source activate test-xtensor-python

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ message(STATUS "xtensor-python v${${PROJECT_NAME}_VERSION}")
3333

3434
set(XTENSOR_PYTHON_HEADERS
3535
${XTENSOR_PYTHON_INCLUDE_DIR}/xtensor-python/pyarray.hpp
36-
${XTENSOR_PYTHON_INCLUDE_DIR}/xtensor-python/pybuffer_adaptor.hpp
3736
${XTENSOR_PYTHON_INCLUDE_DIR}/xtensor-python/pycontainer.hpp
37+
${XTENSOR_PYTHON_INCLUDE_DIR}/xtensor-python/pystrides_adaptor.hpp
3838
${XTENSOR_PYTHON_INCLUDE_DIR}/xtensor-python/pytensor.hpp
3939
${XTENSOR_PYTHON_INCLUDE_DIR}/xtensor-python/pyvectorize.hpp
4040
${XTENSOR_PYTHON_INCLUDE_DIR}/xtensor-python/xtensor_python_config.hpp

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ Both containers enable the numpy-style APIs of xtensor (see [the numpy to xtenso
4949

5050
double sum_of_sines(xt::pyarray<double>& m)
5151
{
52-
auto sines = xt::sin(m); // sines does not actually hold any value, which are only computed upon access
52+
auto sines = xt::sin(m); // sines does not actually hold values.
5353
return std::accumulate(sines.begin(), sines.end(), 0.0);
5454
}
5555

5656
PYBIND11_PLUGIN(xtensor_python_test)
5757
{
5858
pybind11::module m("xtensor_python_test", "Test module for xtensor python bindings");
5959

60-
m.def("sum_of_sines", sum_of_sines, "Computes the sum of the sines of the values of the input array");
60+
m.def("sum_of_sines", sum_of_sines, "Sum the sines of the input values");
6161

6262
return m.ptr();
6363
}
@@ -189,7 +189,7 @@ from the `docs` subdirectory.
189189

190190
| `xtensor-python` | `xtensor` | `pybind11` |
191191
|-------------------|------------|-------------|
192-
| master | ^0.10.0 | ^2.1.0 |
192+
| master | ^0.10.2 | ^2.1.0 |
193193
| 0.11.x | ^0.10.0 | ^2.1.0 |
194194
| 0.10.x | ^0.9.0 | ^2.1.0 |
195195
| 0.9.x | ^0.8.1 | ^2.1.0 |

docs/source/basic_usage.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,18 @@ Example 1: Use an algorithm of the C++ library on a numpy array inplace
2020
#define FORCE_IMPORT_ARRAY // numpy C api loading
2121
#include "xtensor-python/pyarray.hpp" // Numpy bindings
2222
23-
double sum_of_sines(xt::pyarray<double> &m)
23+
double sum_of_sines(xt::pyarray<double>& m)
2424
{
25-
auto sines = xt::sin(m);
26-
// sines does not actually hold any value, which are only computed upon access
27-
return std::accumulate(sines.begin(), sines.end(), 0.0);
25+
auto sines = xt::sin(m); // sines does not actually hold values.
26+
return std::accumulate(sines.cbegin(), sines.cend(), 0.0);
2827
}
2928
3029
PYBIND11_PLUGIN(xtensor_python_test)
3130
{
3231
xt::import_numpy();
3332
pybind11::module m("xtensor_python_test", "Test module for xtensor python bindings");
3433
35-
m.def("sum_of_sines", sum_of_sines,
36-
"Computes the sum of the sines of the values of the input array");
34+
m.def("sum_of_sines", sum_of_sines, "Sum the sines of the input values");
3735
3836
return m.ptr();
3937
}

include/xtensor-python/pyarray.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
#include <cstddef>
1313
#include <vector>
1414
#include <algorithm>
15+
1516
#include "xtensor/xsemantic.hpp"
1617
#include "xtensor/xiterator.hpp"
18+
#include "xtensor/xbuffer_adaptor.hpp"
1719

1820
#include "pycontainer.hpp"
19-
#include "pybuffer_adaptor.hpp"
21+
#include "pystrides_adaptor.hpp"
2022

2123
namespace xt
2224
{
@@ -103,11 +105,11 @@ namespace xt
103105
template <class T>
104106
struct xcontainer_inner_types<pyarray<T>>
105107
{
106-
using container_type = pybuffer_adaptor<T>;
108+
using container_type = xbuffer_adaptor<T>;
107109
using shape_type = std::vector<typename container_type::size_type>;
108110
using strides_type = shape_type;
109111
using backstrides_type = pyarray_backstrides<pyarray<T>>;
110-
using inner_shape_type = pybuffer_adaptor<std::size_t>;
112+
using inner_shape_type = xbuffer_adaptor<std::size_t>;
111113
using inner_strides_type = pystrides_adaptor<sizeof(T)>;
112114
using inner_backstrides_type = backstrides_type;
113115
using temporary_type = pyarray<T>;

0 commit comments

Comments
 (0)