Skip to content

Commit

Permalink
Fixed static analysis build
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanMabille committed Aug 21, 2023
1 parent 5df89c6 commit 566b51b
Show file tree
Hide file tree
Showing 9 changed files with 465 additions and 449 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ repos:
- id: detect-private-key
- id: check-merge-conflict
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.4.2
rev: v1.5.4
hooks:
- id: forbid-tabs
- id: remove-tabs
args: [--whitespaces-count, '4']
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.7.0
rev: v2.10.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2']
Expand All @@ -41,7 +41,7 @@ repos:
files: environment.yaml
# Externally provided executables (so we can use them with editors as well).
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v15.0.7
rev: v16.0.6
hooks:
- id: clang-format
files: .*\.[hc]pp$
18 changes: 12 additions & 6 deletions include/xtensor/xaccumulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ namespace xt
// using return_type = std::conditional_t<std::is_same<init_type, void>::value, typename
// std::decay_t<E>::value_type, init_type>;

using return_type = std::decay_t<decltype(std::declval<accumulate_functor_type>(
)(std::declval<init_type>(), std::declval<expr_value_type>()))>;
using return_type = std::decay_t<decltype(std::declval<accumulate_functor_type>()(
std::declval<init_type>(),
std::declval<expr_value_type>()
))>;

using result_type = xaccumulator_return_type_t<std::decay_t<E>, return_type>;

Expand Down Expand Up @@ -281,8 +283,10 @@ namespace xt
{
for (std::size_t j = 0; j < inner_loop_size; ++j)
{
res.storage()[pos + inner_stride] = xt::get<0>(f
)(res.storage()[pos], res.storage()[pos + inner_stride]);
res.storage()[pos + inner_stride] = xt::get<0>(f)(
res.storage()[pos],
res.storage()[pos + inner_stride]
);

pos += outer_stride;
}
Expand All @@ -298,8 +302,10 @@ namespace xt
using init_type = typename F::init_value_type;
using expr_value_type = typename std::decay_t<E>::value_type;
using accumulate_functor_type = typename F::accumulate_functor_type;
using return_type = std::decay_t<decltype(std::declval<accumulate_functor_type>(
)(std::declval<init_type>(), std::declval<expr_value_type>()))>;
using return_type = std::decay_t<decltype(std::declval<accumulate_functor_type>()(
std::declval<init_type>(),
std::declval<expr_value_type>()
))>;
// using return_type = std::conditional_t<std::is_same<init_type, void>::value, typename
// std::decay_t<E>::value_type, init_type>;

Expand Down
4 changes: 2 additions & 2 deletions include/xtensor/xfunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ namespace xt
struct xcontainer_inner_types<xfunction<F, CT...>>
{
// Added indirection for MSVC 2017 bug with the operator value_type()
using func_return_type = typename meta_identity<decltype(std::declval<F>(
)(std::declval<xvalue_type_t<std::decay_t<CT>>>()...))>::type;
using func_return_type = typename meta_identity<
decltype(std::declval<F>()(std::declval<xvalue_type_t<std::decay_t<CT>>>()...))>::type;
using value_type = std::decay_t<func_return_type>;
using reference = func_return_type;
using const_reference = reference;
Expand Down
5 changes: 3 additions & 2 deletions include/xtensor/xhistogram.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,9 @@ namespace xt
XTENSOR_THROW(std::runtime_error, "Data argument for bincount can only contain positive integers!");
}

xt::xtensor<result_value_type, 1> res = xt::zeros<result_value_type>({(std::max
)(minlength, std::size_t(left_right[1] + 1))});
xt::xtensor<result_value_type, 1> res = xt::zeros<result_value_type>(
{(std::max)(minlength, std::size_t(left_right[1] + 1))}
);

for (size_type i = 0; i < data.size(); ++i)
{
Expand Down
4 changes: 2 additions & 2 deletions include/xtensor/xmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1757,8 +1757,8 @@ namespace xt
auto d = math::abs(internal_type(a) - internal_type(b));
return d <= m_atol
|| d <= m_rtol
* double((std::max
)(math::abs(internal_type(a)), math::abs(internal_type(b))));
* double((std::max)(math::abs(internal_type(a)), math::abs(internal_type(b)))
);
}

private:
Expand Down
18 changes: 12 additions & 6 deletions include/xtensor/xreducer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,10 @@ namespace xt
using reduce_functor_type = typename std::decay_t<F>::reduce_functor_type;
using init_functor_type = typename std::decay_t<F>::init_functor_type;
using expr_value_type = typename std::decay_t<E>::value_type;
using result_type = std::decay_t<decltype(std::declval<reduce_functor_type>(
)(std::declval<init_functor_type>()(), std::declval<expr_value_type>()))>;
using result_type = std::decay_t<decltype(std::declval<reduce_functor_type>()(
std::declval<init_functor_type>()(),
std::declval<expr_value_type>()
))>;

using options_t = reducer_options<result_type, std::decay_t<O>>;
options_t options(raw_options);
Expand Down Expand Up @@ -767,8 +769,10 @@ namespace xt
using init_functor_type = typename std::decay_t<F>::init_functor_type;
using merge_functor_type = typename std::decay_t<F>::merge_functor_type;
using substepper_type = typename xexpression_type::const_stepper;
using raw_value_type = std::decay_t<decltype(std::declval<reduce_functor_type>(
)(std::declval<init_functor_type>()(), *std::declval<substepper_type>()))>;
using raw_value_type = std::decay_t<decltype(std::declval<reduce_functor_type>()(
std::declval<init_functor_type>()(),
*std::declval<substepper_type>()
))>;
using value_type = typename detail::evaluated_value_type_t<raw_value_type, is_xexpression<raw_value_type>::value>;

using reference = value_type;
Expand Down Expand Up @@ -926,8 +930,10 @@ namespace xt

using reduce_functor_type = typename std::decay_t<F>::reduce_functor_type;
using init_functor_type = typename std::decay_t<F>::init_functor_type;
using value_type = std::decay_t<decltype(std::declval<reduce_functor_type>(
)(std::declval<init_functor_type>()(), *std::declval<typename std::decay_t<E>::const_stepper>()))>;
using value_type = std::decay_t<decltype(std::declval<reduce_functor_type>()(
std::declval<init_functor_type>()(),
*std::declval<typename std::decay_t<E>::const_stepper>()
))>;
using evaluated_value_type = evaluated_value_type_t<value_type, is_xexpression<value_type>::value>;

using reducer_type = xreducer<
Expand Down
5 changes: 3 additions & 2 deletions include/xtensor/xstrides.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,9 @@ namespace xt
inline offset_type element_offset(const S& strides, It first, It last) noexcept
{
using difference_type = typename std::iterator_traits<It>::difference_type;
auto size = static_cast<difference_type>((std::min
)(static_cast<typename S::size_type>(std::distance(first, last)), strides.size()));
auto size = static_cast<difference_type>(
(std::min)(static_cast<typename S::size_type>(std::distance(first, last)), strides.size())
);
return std::inner_product(last - size, last, strides.cend() - size, offset_type(0));
}

Expand Down
10 changes: 6 additions & 4 deletions include/xtensor/xview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1680,8 +1680,9 @@ namespace xt
inline auto xview<CT, S...>::sliced_access(const xslice<T>& slice, Arg arg, Args... args) const -> size_type
{
using ST = typename T::size_type;
return static_cast<size_type>(slice.derived_cast(
)(argument<I>(static_cast<ST>(arg), static_cast<ST>(args)...)));
return static_cast<size_type>(
slice.derived_cast()(argument<I>(static_cast<ST>(arg), static_cast<ST>(args)...))
);
}

template <class CT, class... S>
Expand All @@ -1707,8 +1708,9 @@ namespace xt
return xt::value(s, 0);
};

auto s = static_cast<diff_type>((std::min
)(static_cast<size_type>(std::distance(first, last)), this->dimension()));
auto s = static_cast<diff_type>(
(std::min)(static_cast<size_type>(std::distance(first, last)), this->dimension())
);
auto first_copy = last - s;
for (size_type i = 0; i != m_e.dimension(); ++i)
{
Expand Down
Loading

0 comments on commit 566b51b

Please sign in to comment.