Skip to content
Open
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
9 changes: 7 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,22 @@ 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}
- {compiler: gcc, version: '13', name: xsimd-tbb, flags: -DXTENSOR_USE_XSIMD=ON -DXTENSOR_USE_TBB=ON}
- {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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions include/xtensor/generators/xbuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::ptrdiff_t>(i) + 1,
shape.end(),
1,
size_t(1),
std::multiplies<size_t>()
);
const auto len = (*(first + i + after_axis));
const auto len = (*(first + static_cast<std::ptrdiff_t>(i + after_axis)));
offset += len * stride;
}
const auto element = arr.begin() + offset;
const auto element = arr.begin() + static_cast<std::ptrdiff_t>(offset);
return *element;
};
size_type i = *(first + axis);
size_type i = *(first + static_cast<std::ptrdiff_t>(axis));
return apply<value_type>(i, get_item, t);
}
};
Expand Down
14 changes: 13 additions & 1 deletion include/xtensor/io/xcsv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <>
Expand All @@ -93,6 +93,18 @@ namespace xt
return std::stoi(cell);
}

template <>
inline signed char lexical_cast<signed char>(const std::string& cell)
{
return static_cast<signed char>(std::stoi(cell));
}

template <>
inline unsigned char lexical_cast<unsigned char>(const std::string& cell)
{
return static_cast<unsigned char>(std::stoul(cell));
}

template <>
inline long lexical_cast<long>(const std::string& cell)
{
Expand Down
10 changes: 6 additions & 4 deletions include/xtensor/views/index_mapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,9 @@ namespace xt
{
constexpr size_t n_indices_full = n_indices_full_v<FirstIndice, OtherIndices...>;

constexpr size_t underlying_n_dimensions = xt::static_dimension<
typename std::decay_t<UnderlyingContainer>::shape_type>::value;
constexpr size_t underlying_n_dimensions = static_cast<size_t>(
xt::static_dimension<typename std::decay_t<UnderlyingContainer>::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
Expand Down Expand Up @@ -462,7 +463,7 @@ namespace xt
const view_type& view
) const -> conditional_reference<IS_CONST>
{
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,
Expand Down Expand Up @@ -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<slice_size_type>(i)));
}
}
else
Expand Down
10 changes: 5 additions & 5 deletions include/xtensor/views/xslice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ namespace xt

type operator()(T t)
{
return (xtl::is_integral<T>::value) ? static_cast<type>(t) : t;
return static_cast<type>(t);
}
};

Expand Down Expand Up @@ -780,7 +780,7 @@ namespace xt
{
if constexpr (is_xslice<S>::value)
{
return slice.size();
return static_cast<std::size_t>(slice.size());
}
else
{
Expand All @@ -797,7 +797,7 @@ namespace xt
{
if constexpr (is_xslice<S>::value)
{
return slice.step_size(idx);
return static_cast<std::size_t>(slice.step_size(idx));
}
else
{
Expand All @@ -810,7 +810,7 @@ namespace xt
{
if constexpr (is_xslice<S>::value)
{
return slice.step_size(idx, n);
return static_cast<std::size_t>(slice.step_size(idx, n));
}
else
{
Expand All @@ -828,7 +828,7 @@ namespace xt
if constexpr (is_xslice<S>::value)
{
using ST = typename S::size_type;
return slice(static_cast<ST>(i));
return static_cast<std::size_t>(slice(static_cast<ST>(i)));
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion include/xtensor/views/xstrided_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ namespace xt
if (iter != std::end(shape))
{
const auto total = std::accumulate(shape.cbegin(), shape.cend(), -1, std::multiplies<int>{});
const auto missing_dimension = size / total;
const auto missing_dimension = size / static_cast<size_t>(total);
(*iter) = static_cast<value_type>(missing_dimension);
}
}
Expand Down
Loading