From 43a7c4cbed1fba431598d5ee582bc3cf2c2b41bd Mon Sep 17 00:00:00 2001 From: Daniel Jacobs Date: Thu, 3 Apr 2025 13:19:13 -0400 Subject: [PATCH 01/10] update xtensor includes --- benchmark/main.cpp | 4 ++-- docs/source/basic_usage.rst | 2 +- include/xtensor-python/pyarray.hpp | 6 +++--- include/xtensor-python/pycontainer.hpp | 2 +- include/xtensor-python/pytensor.hpp | 8 ++++---- include/xtensor-python/pyvectorize.hpp | 2 +- .../xtensor_type_caster_base.hpp | 4 ++-- test/test_common.hpp | 4 ++-- test/test_pyarray.cpp | 4 ++-- test/test_pytensor.cpp | 18 +++++++++--------- test/test_sfinae.cpp | 4 ++-- test_python/main.cpp | 8 ++++---- 12 files changed, 33 insertions(+), 33 deletions(-) diff --git a/benchmark/main.cpp b/benchmark/main.cpp index d1d787e..4c18bc7 100644 --- a/benchmark/main.cpp +++ b/benchmark/main.cpp @@ -2,8 +2,8 @@ #include "pybind11/numpy.h" #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include "numpy/arrayobject.h" -#include "xtensor/xtensor.hpp" -#include "xtensor/xarray.hpp" +#include "xtensor/containers/xtensor.hpp" +#include "xtensor/containers/xarray.hpp" #include "xtensor-python/pyarray.hpp" #include "xtensor-python/pytensor.hpp" #include "xtensor-python/pyvectorize.hpp" diff --git a/docs/source/basic_usage.rst b/docs/source/basic_usage.rst index c97c9ac..32b1c23 100644 --- a/docs/source/basic_usage.rst +++ b/docs/source/basic_usage.rst @@ -16,7 +16,7 @@ Example 1: Use an algorithm of the C++ library on a numpy array inplace #include // Standard library import for std::accumulate #include "pybind11/pybind11.h" // Pybind11 import to define Python bindings - #include "xtensor/xmath.hpp" // xtensor import for the C++ universal functions + #include "xtensor/core/xmath.hpp" // xtensor import for the C++ universal functions #define FORCE_IMPORT_ARRAY // numpy C api loading #include "xtensor-python/pyarray.hpp" // Numpy bindings diff --git a/include/xtensor-python/pyarray.hpp b/include/xtensor-python/pyarray.hpp index 6df73cf..0854fb3 100644 --- a/include/xtensor-python/pyarray.hpp +++ b/include/xtensor-python/pyarray.hpp @@ -14,9 +14,9 @@ #include #include -#include "xtensor/xbuffer_adaptor.hpp" -#include "xtensor/xiterator.hpp" -#include "xtensor/xsemantic.hpp" +#include "xtensor/containers/xbuffer_adaptor.hpp" +#include "xtensor/core/xiterator.hpp" +#include "xtensor/core/xsemantic.hpp" #include "pyarray_backstrides.hpp" #include "pycontainer.hpp" diff --git a/include/xtensor-python/pycontainer.hpp b/include/xtensor-python/pycontainer.hpp index d0a1a1e..5e80a32 100644 --- a/include/xtensor-python/pycontainer.hpp +++ b/include/xtensor-python/pycontainer.hpp @@ -32,7 +32,7 @@ #undef copysign #include -#include "xtensor/xcontainer.hpp" +#include "xtensor/containers/xcontainer.hpp" #include "xtl/xsequence.hpp" diff --git a/include/xtensor-python/pytensor.hpp b/include/xtensor-python/pytensor.hpp index acf05b8..3eac157 100644 --- a/include/xtensor-python/pytensor.hpp +++ b/include/xtensor-python/pytensor.hpp @@ -14,10 +14,10 @@ #include #include -#include "xtensor/xbuffer_adaptor.hpp" -#include "xtensor/xiterator.hpp" -#include "xtensor/xsemantic.hpp" -#include "xtensor/xutils.hpp" +#include "xtensor/containers/xbuffer_adaptor.hpp" +#include "xtensor/core/xiterator.hpp" +#include "xtensor/core/xsemantic.hpp" +#include "xtensor/utils/xutils.hpp" #include "pycontainer.hpp" #include "pystrides_adaptor.hpp" diff --git a/include/xtensor-python/pyvectorize.hpp b/include/xtensor-python/pyvectorize.hpp index 9c7d107..d96f689 100644 --- a/include/xtensor-python/pyvectorize.hpp +++ b/include/xtensor-python/pyvectorize.hpp @@ -13,7 +13,7 @@ #include #include "pyarray.hpp" -#include "xtensor/xvectorize.hpp" +#include "xtensor/core/xvectorize.hpp" namespace xt { diff --git a/include/xtensor-python/xtensor_type_caster_base.hpp b/include/xtensor-python/xtensor_type_caster_base.hpp index 840e28c..902235f 100644 --- a/include/xtensor-python/xtensor_type_caster_base.hpp +++ b/include/xtensor-python/xtensor_type_caster_base.hpp @@ -14,8 +14,8 @@ #include #include -#include "xtensor/xtensor.hpp" -#include "xtensor/xfixed.hpp" +#include "xtensor/containers/xtensor.hpp" +#include "xtensor/containers/xfixed.hpp" #include #include diff --git a/test/test_common.hpp b/test/test_common.hpp index 3b4ed85..7115764 100644 --- a/test/test_common.hpp +++ b/test/test_common.hpp @@ -10,8 +10,8 @@ #ifndef TEST_COMMON_HPP #define TEST_COMMON_HPP -#include "xtensor/xlayout.hpp" -#include "xtensor/xmanipulation.hpp" +#include "xtensor/core/xlayout.hpp" +#include "xtensor/misc/xmanipulation.hpp" #include "xtl/xsequence.hpp" diff --git a/test/test_pyarray.cpp b/test/test_pyarray.cpp index 6406de6..15ede7e 100644 --- a/test/test_pyarray.cpp +++ b/test/test_pyarray.cpp @@ -11,8 +11,8 @@ #include "xtensor-python/pyarray.hpp" -#include "xtensor/xarray.hpp" -#include "xtensor/xview.hpp" +#include "xtensor/containers/xarray.hpp" +#include "xtensor/views/xview.hpp" #include "test_common.hpp" diff --git a/test/test_pytensor.cpp b/test/test_pytensor.cpp index f2ac013..c7b12cf 100644 --- a/test/test_pytensor.cpp +++ b/test/test_pytensor.cpp @@ -11,8 +11,8 @@ #include "xtensor-python/pytensor.hpp" -#include "xtensor/xtensor.hpp" -#include "xtensor/xview.hpp" +#include "xtensor/containers/xtensor.hpp" +#include "xtensor/views/xview.hpp" #include "test_common.hpp" @@ -22,13 +22,13 @@ namespace xt TEST(pytensor, initializer_constructor) { - pytensor t - {{{ 0, 1, 2}, - { 3, 4, 5}, - { 6, 7, 8}}, - {{ 9, 10, 11}, - {12, 13, 14}, - {15, 16, 17}}}; + pytensor t + {{{ 0, 1, 2}, + { 3, 4, 5}, + { 6, 7, 8}}, + {{ 9, 10, 11}, + {12, 13, 14}, + {15, 16, 17}}}; EXPECT_EQ(t.dimension(), 3); EXPECT_EQ(t(0, 0, 1), 1); EXPECT_EQ(t.shape()[0], 2); diff --git a/test/test_sfinae.cpp b/test/test_sfinae.cpp index a614485..c9d4733 100644 --- a/test/test_sfinae.cpp +++ b/test/test_sfinae.cpp @@ -12,8 +12,8 @@ #include "gtest/gtest.h" #include "xtensor-python/pytensor.hpp" #include "xtensor-python/pyarray.hpp" -#include "xtensor/xarray.hpp" -#include "xtensor/xtensor.hpp" +#include "xtensor/containers/xarray.hpp" +#include "xtensor/containers/xtensor.hpp" namespace xt { diff --git a/test_python/main.cpp b/test_python/main.cpp index 7a0c524..82810f7 100644 --- a/test_python/main.cpp +++ b/test_python/main.cpp @@ -9,9 +9,9 @@ #include -#include "xtensor/xmath.hpp" -#include "xtensor/xarray.hpp" -#include "xtensor/xfixed.hpp" +#include "xtensor/core/xmath.hpp" +#include "xtensor/containers/xarray.hpp" +#include "xtensor/containers/xfixed.hpp" #define FORCE_IMPORT_ARRAY #include "xtensor-python/pyarray.hpp" #include "xtensor-python/pytensor.hpp" @@ -336,7 +336,7 @@ PYBIND11_MODULE(xtensor_python_test, m) m.def("array_subtraction", array_subtraction); m.def("array_multiplication", array_multiplication); m.def("array_division", array_division); - + m.def("vectorize_example1", xt::pyvectorize(add)); m.def("rect_to_polar", xt::pyvectorize([](complex_t x) { return std::abs(x); })); From 40c489b7040a48dfbfddd67b8e25389ed759cfdd Mon Sep 17 00:00:00 2001 From: Daniel Jacobs Date: Sat, 5 Apr 2025 18:16:42 -0400 Subject: [PATCH 02/10] update xtensor version --- CMakeLists.txt | 4 ++-- README.md | 2 +- environment-dev.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bcf8df5..3fe3f34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,14 +25,14 @@ foreach(ver ${xtensor_python_version_defines}) set(XTENSOR_PYTHON_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "") endif() endforeach() -set(${PROJECT_NAME}_VERSION +set(${PROJECT_NAME}_VERSION ${XTENSOR_PYTHON_VERSION_MAJOR}.${XTENSOR_PYTHON_VERSION_MINOR}.${XTENSOR_PYTHON_VERSION_PATCH}) message(STATUS "xtensor-python v${${PROJECT_NAME}_VERSION}") # Dependencies # ============ -set(xtensor_REQUIRED_VERSION 0.25.0) +set(xtensor_REQUIRED_VERSION 0.26.0) if(TARGET xtensor) set(xtensor_VERSION ${XTENSOR_VERSION_MAJOR}.${XTENSOR_VERSION_MINOR}.${XTENSOR_VERSION_PATCH}) # Note: This is not SEMVER compatible comparison diff --git a/README.md b/README.md index 2cff672..88e6898 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ from the `docs` subdirectory. | `xtensor-python` | `xtensor` | `pybind11` | |------------------|-----------|------------------| -| master | ^0.25.0 | >=2.6.1,<3 | +| master | ^0.26.0 | >=2.6.1,<3 | | 0.27.0 | ^0.25.0 | >=2.6.1,<3 | | 0.26.1 | ^0.24.0 | ~2.4.3 | | 0.26.0 | ^0.24.0 | ~2.4.3 | diff --git a/environment-dev.yml b/environment-dev.yml index f203855..72275dd 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -6,7 +6,7 @@ dependencies: - cmake - ninja # Host dependencies - - xtensor>=0.25,<0.26 + - xtensor>=0.26,<0.27 - numpy>=2.0 - pybind11>=2.12.0,<3 # Test dependencies From 24cceaac2cfce63387a5de91e3535d12c7b66e1e Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Mon, 14 Apr 2025 09:05:34 +0200 Subject: [PATCH 03/10] BUild in C++17 --- test/CMakeLists.txt | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index aaaf339..3175eef 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -29,16 +29,7 @@ include(CheckCXXCompilerFlag) string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE) -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion -fvisibility=hidden") - CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) - - if (HAS_CPP14_FLAG) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") - else() - message(FATAL_ERROR "Unsupported compiler -- xtensor requires C++14 support!") - endif() -endif() +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=C++17") if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj") From 5ca0695434ca162b64c367be9a6ad71286eec128 Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Mon, 14 Apr 2025 09:07:41 +0200 Subject: [PATCH 04/10] .. --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3175eef..60fcf10 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -29,7 +29,7 @@ include(CheckCXXCompilerFlag) string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=C++17") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj") From 4218048242a73d43498a7dbaf6511bd41bd1e8a0 Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Mon, 14 Apr 2025 09:14:09 +0200 Subject: [PATCH 05/10] Fixed includes in python tests --- test_python/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_python/main.cpp b/test_python/main.cpp index 82810f7..d9b9e97 100644 --- a/test_python/main.cpp +++ b/test_python/main.cpp @@ -16,8 +16,8 @@ #include "xtensor-python/pyarray.hpp" #include "xtensor-python/pytensor.hpp" #include "xtensor-python/pyvectorize.hpp" -#include "xtensor/xadapt.hpp" -#include "xtensor/xstrided_view.hpp" +#include "xtensor/containers/xadapt.hpp" +#include "xtensor/views/xstrided_view.hpp" namespace py = pybind11; using complex_t = std::complex; From 220d6908628f89dd7ec491460e80d8b7a823bac9 Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Mon, 14 Apr 2025 09:16:55 +0200 Subject: [PATCH 06/10] Fixed standard version in python tests --- test_python/setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test_python/setup.py b/test_python/setup.py index fa201da..96eaa15 100644 --- a/test_python/setup.py +++ b/test_python/setup.py @@ -78,10 +78,10 @@ def cpp_flag(compiler): """Return the -std=c++14 compiler flag and errors when the flag is no available. """ - if has_flag(compiler, '-std=c++14'): - return '-std=c++14' + if has_flag(compiler, '-std=c++17'): + return '-std=c++17' else: - raise RuntimeError('C++14 support is required by xtensor!') + raise RuntimeError('C++17 support is required by xtensor!') class BuildExt(build_ext): From 770d9b7ea9d4e7f540099216f8f5229d6b17f4c5 Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Mon, 14 Apr 2025 09:34:44 +0200 Subject: [PATCH 07/10] Fixed includes in examples --- docs/source/examples/sfinae/mymodule.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/examples/sfinae/mymodule.hpp b/docs/source/examples/sfinae/mymodule.hpp index 5127eff..33f7b8a 100644 --- a/docs/source/examples/sfinae/mymodule.hpp +++ b/docs/source/examples/sfinae/mymodule.hpp @@ -1,4 +1,4 @@ -#include +#include namespace mymodule { From ebfbb1a3ecb074b57eff5ba6827f0ff9de9dc315 Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Mon, 14 Apr 2025 09:51:11 +0200 Subject: [PATCH 08/10] .. --- docs/source/examples/sfinae/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/examples/sfinae/main.cpp b/docs/source/examples/sfinae/main.cpp index a146cdd..44ffaa7 100644 --- a/docs/source/examples/sfinae/main.cpp +++ b/docs/source/examples/sfinae/main.cpp @@ -1,5 +1,5 @@ #include "mymodule.hpp" -#include +#include int main() { From 9d60272886ac34340cc3953dc9c1bcd666365294 Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Mon, 14 Apr 2025 09:56:02 +0200 Subject: [PATCH 09/10] Upgraded mac os minimum version in python tests --- test_python/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_python/setup.py b/test_python/setup.py index 96eaa15..efef118 100644 --- a/test_python/setup.py +++ b/test_python/setup.py @@ -92,7 +92,7 @@ class BuildExt(build_ext): } if sys.platform == 'darwin': - c_opts['unix'] += ['-stdlib=libc++', '-mmacosx-version-min=10.7'] + c_opts['unix'] += ['-stdlib=libc++', '-mmacosx-version-min=10.13'] def build_extensions(self): ct = self.compiler.compiler_type From cc7e8259aa4b228e2e68a10c951a5670b6de5038 Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Mon, 14 Apr 2025 10:10:02 +0200 Subject: [PATCH 10/10] Set c++17 on Windows --- test_python/setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test_python/setup.py b/test_python/setup.py index efef118..58dbd2d 100644 --- a/test_python/setup.py +++ b/test_python/setup.py @@ -75,7 +75,7 @@ def has_flag(compiler, flagname): def cpp_flag(compiler): - """Return the -std=c++14 compiler flag and errors when the flag is + """Return the -std=c++17 compiler flag and errors when the flag is no available. """ if has_flag(compiler, '-std=c++17'): @@ -104,6 +104,7 @@ def build_extensions(self): opts.append('-fvisibility=hidden') elif ct == 'msvc': opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version()) + opts.append('/std:c++17') for ext in self.extensions: ext.extra_compile_args = opts build_ext.build_extensions(self)