Skip to content

Commit f555d12

Browse files
danielcjacobsDaniel JacobsJohanMabille
authored
update xtensor includes (#317)
Brings xtensor-python up to date with latest xtensor release (0.26.0), where xtensor-stack/xtensor#2829 reorganized the include directory. --------- Co-authored-by: Daniel Jacobs <[email protected]> Co-authored-by: Johan Mabille <[email protected]>
1 parent 1c85ed8 commit f555d12

19 files changed

+48
-56
lines changed

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ foreach(ver ${xtensor_python_version_defines})
2525
set(XTENSOR_PYTHON_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "")
2626
endif()
2727
endforeach()
28-
set(${PROJECT_NAME}_VERSION
28+
set(${PROJECT_NAME}_VERSION
2929
${XTENSOR_PYTHON_VERSION_MAJOR}.${XTENSOR_PYTHON_VERSION_MINOR}.${XTENSOR_PYTHON_VERSION_PATCH})
3030
message(STATUS "xtensor-python v${${PROJECT_NAME}_VERSION}")
3131

3232
# Dependencies
3333
# ============
3434

35-
set(xtensor_REQUIRED_VERSION 0.25.0)
35+
set(xtensor_REQUIRED_VERSION 0.26.0)
3636
if(TARGET xtensor)
3737
set(xtensor_VERSION ${XTENSOR_VERSION_MAJOR}.${XTENSOR_VERSION_MINOR}.${XTENSOR_VERSION_PATCH})
3838
# Note: This is not SEMVER compatible comparison

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ from the `docs` subdirectory.
204204

205205
| `xtensor-python` | `xtensor` | `pybind11` |
206206
|------------------|-----------|------------------|
207-
| master | ^0.25.0 | >=2.6.1,<3 |
207+
| master | ^0.26.0 | >=2.6.1,<3 |
208208
| 0.27.0 | ^0.25.0 | >=2.6.1,<3 |
209209
| 0.26.1 | ^0.24.0 | ~2.4.3 |
210210
| 0.26.0 | ^0.24.0 | ~2.4.3 |

benchmark/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#include "pybind11/numpy.h"
33
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
44
#include "numpy/arrayobject.h"
5-
#include "xtensor/xtensor.hpp"
6-
#include "xtensor/xarray.hpp"
5+
#include "xtensor/containers/xtensor.hpp"
6+
#include "xtensor/containers/xarray.hpp"
77
#include "xtensor-python/pyarray.hpp"
88
#include "xtensor-python/pytensor.hpp"
99
#include "xtensor-python/pyvectorize.hpp"

docs/source/basic_usage.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Example 1: Use an algorithm of the C++ library on a numpy array inplace
1616
1717
#include <numeric> // Standard library import for std::accumulate
1818
#include "pybind11/pybind11.h" // Pybind11 import to define Python bindings
19-
#include "xtensor/xmath.hpp" // xtensor import for the C++ universal functions
19+
#include "xtensor/core/xmath.hpp" // xtensor import for the C++ universal functions
2020
#define FORCE_IMPORT_ARRAY // numpy C api loading
2121
#include "xtensor-python/pyarray.hpp" // Numpy bindings
2222

docs/source/examples/sfinae/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "mymodule.hpp"
2-
#include <xtensor/xio.hpp>
2+
#include <xtensor/io/xio.hpp>
33

44
int main()
55
{

docs/source/examples/sfinae/mymodule.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <xtensor/xtensor.hpp>
1+
#include <xtensor/containers/xtensor.hpp>
22

33
namespace mymodule {
44

environment-dev.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66
- cmake
77
- ninja
88
# Host dependencies
9-
- xtensor>=0.25,<0.26
9+
- xtensor>=0.26,<0.27
1010
- numpy>=2.0
1111
- pybind11>=2.12.0,<3
1212
# Test dependencies

include/xtensor-python/pyarray.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
#include <cstddef>
1515
#include <vector>
1616

17-
#include "xtensor/xbuffer_adaptor.hpp"
18-
#include "xtensor/xiterator.hpp"
19-
#include "xtensor/xsemantic.hpp"
17+
#include "xtensor/containers/xbuffer_adaptor.hpp"
18+
#include "xtensor/core/xiterator.hpp"
19+
#include "xtensor/core/xsemantic.hpp"
2020

2121
#include "pyarray_backstrides.hpp"
2222
#include "pycontainer.hpp"

include/xtensor-python/pycontainer.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#undef copysign
3333

3434
#include <cmath>
35-
#include "xtensor/xcontainer.hpp"
35+
#include "xtensor/containers/xcontainer.hpp"
3636

3737
#include "xtl/xsequence.hpp"
3838

include/xtensor-python/pytensor.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
#include <array>
1515
#include <cstddef>
1616

17-
#include "xtensor/xbuffer_adaptor.hpp"
18-
#include "xtensor/xiterator.hpp"
19-
#include "xtensor/xsemantic.hpp"
20-
#include "xtensor/xutils.hpp"
17+
#include "xtensor/containers/xbuffer_adaptor.hpp"
18+
#include "xtensor/core/xiterator.hpp"
19+
#include "xtensor/core/xsemantic.hpp"
20+
#include "xtensor/utils/xutils.hpp"
2121

2222
#include "pycontainer.hpp"
2323
#include "pystrides_adaptor.hpp"

include/xtensor-python/pyvectorize.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <type_traits>
1414

1515
#include "pyarray.hpp"
16-
#include "xtensor/xvectorize.hpp"
16+
#include "xtensor/core/xvectorize.hpp"
1717

1818
namespace xt
1919
{

include/xtensor-python/xtensor_type_caster_base.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include <algorithm>
1515
#include <vector>
1616

17-
#include "xtensor/xtensor.hpp"
18-
#include "xtensor/xfixed.hpp"
17+
#include "xtensor/containers/xtensor.hpp"
18+
#include "xtensor/containers/xfixed.hpp"
1919

2020
#include <pybind11/numpy.h>
2121
#include <pybind11/pybind11.h>

test/CMakeLists.txt

+1-10
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,7 @@ include(CheckCXXCompilerFlag)
2929

3030
string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE)
3131

32-
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
33-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion -fvisibility=hidden")
34-
CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG)
35-
36-
if (HAS_CPP14_FLAG)
37-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
38-
else()
39-
message(FATAL_ERROR "Unsupported compiler -- xtensor requires C++14 support!")
40-
endif()
41-
endif()
32+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
4233

4334
if(MSVC)
4435
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj")

test/test_common.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#ifndef TEST_COMMON_HPP
1111
#define TEST_COMMON_HPP
1212

13-
#include "xtensor/xlayout.hpp"
14-
#include "xtensor/xmanipulation.hpp"
13+
#include "xtensor/core/xlayout.hpp"
14+
#include "xtensor/misc/xmanipulation.hpp"
1515

1616
#include "xtl/xsequence.hpp"
1717

test/test_pyarray.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
#include "xtensor-python/pyarray.hpp"
1313

14-
#include "xtensor/xarray.hpp"
15-
#include "xtensor/xview.hpp"
14+
#include "xtensor/containers/xarray.hpp"
15+
#include "xtensor/views/xview.hpp"
1616

1717
#include "test_common.hpp"
1818

test/test_pytensor.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
#include "xtensor-python/pytensor.hpp"
1313

14-
#include "xtensor/xtensor.hpp"
15-
#include "xtensor/xview.hpp"
14+
#include "xtensor/containers/xtensor.hpp"
15+
#include "xtensor/views/xview.hpp"
1616

1717
#include "test_common.hpp"
1818

@@ -22,13 +22,13 @@ namespace xt
2222

2323
TEST(pytensor, initializer_constructor)
2424
{
25-
pytensor<int, 3> t
26-
{{{ 0, 1, 2},
27-
{ 3, 4, 5},
28-
{ 6, 7, 8}},
29-
{{ 9, 10, 11},
30-
{12, 13, 14},
31-
{15, 16, 17}}};
25+
pytensor<int, 3> t
26+
{{{ 0, 1, 2},
27+
{ 3, 4, 5},
28+
{ 6, 7, 8}},
29+
{{ 9, 10, 11},
30+
{12, 13, 14},
31+
{15, 16, 17}}};
3232
EXPECT_EQ(t.dimension(), 3);
3333
EXPECT_EQ(t(0, 0, 1), 1);
3434
EXPECT_EQ(t.shape()[0], 2);

test/test_sfinae.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#include "gtest/gtest.h"
1313
#include "xtensor-python/pytensor.hpp"
1414
#include "xtensor-python/pyarray.hpp"
15-
#include "xtensor/xarray.hpp"
16-
#include "xtensor/xtensor.hpp"
15+
#include "xtensor/containers/xarray.hpp"
16+
#include "xtensor/containers/xtensor.hpp"
1717

1818
namespace xt
1919
{

test_python/main.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99

1010
#include <numeric>
1111

12-
#include "xtensor/xmath.hpp"
13-
#include "xtensor/xarray.hpp"
14-
#include "xtensor/xfixed.hpp"
12+
#include "xtensor/core/xmath.hpp"
13+
#include "xtensor/containers/xarray.hpp"
14+
#include "xtensor/containers/xfixed.hpp"
1515
#define FORCE_IMPORT_ARRAY
1616
#include "xtensor-python/pyarray.hpp"
1717
#include "xtensor-python/pytensor.hpp"
1818
#include "xtensor-python/pyvectorize.hpp"
19-
#include "xtensor/xadapt.hpp"
20-
#include "xtensor/xstrided_view.hpp"
19+
#include "xtensor/containers/xadapt.hpp"
20+
#include "xtensor/views/xstrided_view.hpp"
2121

2222
namespace py = pybind11;
2323
using complex_t = std::complex<double>;
@@ -336,7 +336,7 @@ PYBIND11_MODULE(xtensor_python_test, m)
336336
m.def("array_subtraction", array_subtraction);
337337
m.def("array_multiplication", array_multiplication);
338338
m.def("array_division", array_division);
339-
339+
340340
m.def("vectorize_example1", xt::pyvectorize(add));
341341

342342
m.def("rect_to_polar", xt::pyvectorize([](complex_t x) { return std::abs(x); }));

test_python/setup.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ def has_flag(compiler, flagname):
7575

7676

7777
def cpp_flag(compiler):
78-
"""Return the -std=c++14 compiler flag and errors when the flag is
78+
"""Return the -std=c++17 compiler flag and errors when the flag is
7979
no available.
8080
"""
81-
if has_flag(compiler, '-std=c++14'):
82-
return '-std=c++14'
81+
if has_flag(compiler, '-std=c++17'):
82+
return '-std=c++17'
8383
else:
84-
raise RuntimeError('C++14 support is required by xtensor!')
84+
raise RuntimeError('C++17 support is required by xtensor!')
8585

8686

8787
class BuildExt(build_ext):
@@ -92,7 +92,7 @@ class BuildExt(build_ext):
9292
}
9393

9494
if sys.platform == 'darwin':
95-
c_opts['unix'] += ['-stdlib=libc++', '-mmacosx-version-min=10.7']
95+
c_opts['unix'] += ['-stdlib=libc++', '-mmacosx-version-min=10.13']
9696

9797
def build_extensions(self):
9898
ct = self.compiler.compiler_type
@@ -104,6 +104,7 @@ def build_extensions(self):
104104
opts.append('-fvisibility=hidden')
105105
elif ct == 'msvc':
106106
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
107+
opts.append('/std:c++17')
107108
for ext in self.extensions:
108109
ext.extra_compile_args = opts
109110
build_ext.build_extensions(self)

0 commit comments

Comments
 (0)