diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a4de87fb8..ab23283c5 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -23,6 +23,9 @@ jobs: - {compiler: clang, version: '19', name: assert, flags: -DXTENSOR_ENABLE_ASSERT=ON} - {compiler: clang, version: '20', name: column-major, flags: -DDEFAULT_COLUMN_MAJOR=ON} - {compiler: clang, version: '21', name: assert, flags: -DXTENSOR_ENABLE_ASSERT=ON} + - {compiler: clang, version: '21', name: column-major, flags: -DDEFAULT_COLUMN_MAJOR=ON} + - {compiler: clang, version: '22', name: assert, flags: -DXTENSOR_ENABLE_ASSERT=ON} + - {compiler: clang, version: '22', name: column-major, flags: -DDEFAULT_COLUMN_MAJOR=ON} - {compiler: gcc, version: '11', name: openmp, flags: -DXTENSOR_USE_OPENMP=ON} - {compiler: gcc, version: '11', name: noexcept, flags: -DXTENSOR_DISABLE_EXCEPTIONS=ON} - {compiler: gcc, version: '12', name: xsimd, flags: -DXTENSOR_USE_XSIMD=ON} @@ -30,10 +33,12 @@ jobs: - {compiler: gcc, version: '13', name: tbb, flags: -DXTENSOR_USE_TBB=ON -DTBB_INCLUDE_DIR=$CONDA_PREFIX/include -DTBB_LIBRARY=$CONDA_PREFIX/lib} - {compiler: gcc, version: '14', name: xsimd-tbb, flags: -DXTENSOR_USE_XSIMD=ON -DXTENSOR_USE_TBB=ON} - {compiler: gcc, version: '14', name: tbb, flags: -DXTENSOR_USE_TBB=ON -DTBB_INCLUDE_DIR=$CONDA_PREFIX/include -DTBB_LIBRARY=$CONDA_PREFIX/lib} + - {compiler: gcc, version: '15', name: xsimd-tbb, flags: -DXTENSOR_USE_XSIMD=ON -DXTENSOR_USE_TBB=ON} + - {compiler: gcc, version: '15', name: tbb, flags: -DXTENSOR_USE_TBB=ON -DTBB_INCLUDE_DIR=$CONDA_PREFIX/include -DTBB_LIBRARY=$CONDA_PREFIX/lib} steps: - name: Install GCC if: matrix.sys.compiler == 'gcc' - uses: egor-tensin/setup-gcc@v1 + uses: egor-tensin/setup-gcc@v2 with: version: ${{matrix.sys.version}} platform: x64 @@ -53,7 +58,7 @@ jobs: sudo update-alternatives --set clang-scan-deps /usr/bin/clang-scan-deps-${{matrix.sys.version}} - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set conda environment uses: mamba-org/setup-micromamba@main diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index e3204614b..64fe21244 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -10,8 +10,8 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: pre-commit/action@v3.0.0 + - uses: actions/checkout@v6 + - uses: pre-commit/action@v3.0.1 include-check: runs-on: ubuntu-latest diff --git a/include/xtensor/generators/xbuilder.hpp b/include/xtensor/generators/xbuilder.hpp index 5ba9f7a36..55b066c1e 100644 --- a/include/xtensor/generators/xbuilder.hpp +++ b/include/xtensor/generators/xbuilder.hpp @@ -574,18 +574,18 @@ namespace xt } const auto& shape = arr.shape(); const size_t stride = std::accumulate( - shape.begin() + i + 1, + shape.begin() + static_cast(i) + 1, shape.end(), - 1, + size_t(1), std::multiplies() ); - const auto len = (*(first + i + after_axis)); + const auto len = (*(first + static_cast(i + after_axis))); offset += len * stride; } - const auto element = arr.begin() + offset; + const auto element = arr.begin() + static_cast(offset); return *element; }; - size_type i = *(first + axis); + size_type i = *(first + static_cast(axis)); return apply(i, get_item, t); } }; diff --git a/include/xtensor/io/xcsv.hpp b/include/xtensor/io/xcsv.hpp index 080ccaf54..2fd347745 100644 --- a/include/xtensor/io/xcsv.hpp +++ b/include/xtensor/io/xcsv.hpp @@ -66,7 +66,7 @@ namespace xt } size_t last = cell.find_last_not_of(' '); - return cell.substr(first, last == std::string::npos ? cell.size() : last + 1); + return cell.substr(first, last == std::string::npos ? cell.size() : last - first + 1); } template <> @@ -93,6 +93,18 @@ namespace xt return std::stoi(cell); } + template <> + inline signed char lexical_cast(const std::string& cell) + { + return static_cast(std::stoi(cell)); + } + + template <> + inline unsigned char lexical_cast(const std::string& cell) + { + return static_cast(std::stoul(cell)); + } + template <> inline long lexical_cast(const std::string& cell) { diff --git a/include/xtensor/views/index_mapper.hpp b/include/xtensor/views/index_mapper.hpp index 84685f28a..341d941de 100644 --- a/include/xtensor/views/index_mapper.hpp +++ b/include/xtensor/views/index_mapper.hpp @@ -402,8 +402,9 @@ namespace xt { constexpr size_t n_indices_full = n_indices_full_v; - constexpr size_t underlying_n_dimensions = xt::static_dimension< - typename std::decay_t::shape_type>::value; + constexpr size_t underlying_n_dimensions = static_cast( + xt::static_dimension::shape_type>::value + ); // If there is too many indices, we need to drop the first ones. // If the number of dimensions of the underlying container is known at compile time we can drop them @@ -462,7 +463,7 @@ namespace xt const view_type& view ) const -> conditional_reference { - constexpr size_t n_indices_full = n_indices_full_v<>; + constexpr size_t n_indices_full = nb_integral_slices; return map_all_indices( is_const, @@ -517,8 +518,9 @@ namespace xt } else { + using slice_size_type = typename current_slice::size_type; assert(i < slice.size()); - return size_t(slice(i)); + return size_t(slice(static_cast(i))); } } else diff --git a/include/xtensor/views/xslice.hpp b/include/xtensor/views/xslice.hpp index a7a4dae6e..b72750006 100644 --- a/include/xtensor/views/xslice.hpp +++ b/include/xtensor/views/xslice.hpp @@ -718,7 +718,7 @@ namespace xt type operator()(T t) { - return (xtl::is_integral::value) ? static_cast(t) : t; + return static_cast(t); } }; @@ -780,7 +780,7 @@ namespace xt { if constexpr (is_xslice::value) { - return slice.size(); + return static_cast(slice.size()); } else { @@ -797,7 +797,7 @@ namespace xt { if constexpr (is_xslice::value) { - return slice.step_size(idx); + return static_cast(slice.step_size(idx)); } else { @@ -810,7 +810,7 @@ namespace xt { if constexpr (is_xslice::value) { - return slice.step_size(idx, n); + return static_cast(slice.step_size(idx, n)); } else { @@ -828,7 +828,7 @@ namespace xt if constexpr (is_xslice::value) { using ST = typename S::size_type; - return slice(static_cast(i)); + return static_cast(slice(static_cast(i))); } else { diff --git a/include/xtensor/views/xstrided_view.hpp b/include/xtensor/views/xstrided_view.hpp index aa84b20a7..3faff70c8 100644 --- a/include/xtensor/views/xstrided_view.hpp +++ b/include/xtensor/views/xstrided_view.hpp @@ -833,7 +833,7 @@ namespace xt if (iter != std::end(shape)) { const auto total = std::accumulate(shape.cbegin(), shape.cend(), -1, std::multiplies{}); - const auto missing_dimension = size / total; + const auto missing_dimension = size / static_cast(total); (*iter) = static_cast(missing_dimension); } }