diff --git a/include/xtensor/containers/xarray.hpp b/include/xtensor/containers/xarray.hpp index 7f27bd296..1232baf85 100644 --- a/include/xtensor/containers/xarray.hpp +++ b/include/xtensor/containers/xarray.hpp @@ -253,7 +253,7 @@ namespace xt xarray_adaptor& operator=(const xexpression& e); template - void reset_buffer(P&& pointer, S&& size); + void reset_buffer(P&& buffer, S&& size); private: @@ -657,9 +657,9 @@ namespace xt template template - inline void xarray_adaptor::reset_buffer(P&& pointer, S&& size) + inline void xarray_adaptor::reset_buffer(P&& buffer, S&& size) { - return m_storage.reset_data(std::forward

(pointer), std::forward(size)); + return m_storage.reset_data(std::forward

(buffer), std::forward(size)); } } diff --git a/include/xtensor/containers/xtensor.hpp b/include/xtensor/containers/xtensor.hpp index db8d92385..7145ead43 100644 --- a/include/xtensor/containers/xtensor.hpp +++ b/include/xtensor/containers/xtensor.hpp @@ -249,7 +249,7 @@ namespace xt xtensor_adaptor& operator=(const xexpression& e); template - void reset_buffer(P&& pointer, S&& size); + void reset_buffer(P&& buffer, S&& size); private: @@ -720,9 +720,9 @@ namespace xt template template - inline void xtensor_adaptor::reset_buffer(P&& pointer, S&& size) + inline void xtensor_adaptor::reset_buffer(P&& buffer, S&& size) { - return m_storage.reset_data(std::forward

(pointer), std::forward(size)); + return m_storage.reset_data(std::forward

(buffer), std::forward(size)); } /******************************* diff --git a/include/xtensor/core/xshape.hpp b/include/xtensor/core/xshape.hpp index 1380f4e07..36dfd2a7d 100644 --- a/include/xtensor/core/xshape.hpp +++ b/include/xtensor/core/xshape.hpp @@ -197,7 +197,7 @@ namespace xt }; template - constexpr R initializer_shape(U t, std::index_sequence) + constexpr R initializer_shape([[maybe_unused]] U t, std::index_sequence) { using size_type = typename R::value_type; return {size_type(initializer_shape_impl::value(t))...}; diff --git a/include/xtensor/io/xio.hpp b/include/xtensor/io/xio.hpp index 09ee4da58..769e2f986 100644 --- a/include/xtensor/io/xio.hpp +++ b/include/xtensor/io/xio.hpp @@ -302,8 +302,8 @@ namespace xt using cache_type = std::vector; using cache_iterator = typename cache_type::const_iterator; - explicit printer(std::streamsize precision) - : m_precision(precision) + explicit printer(std::streamsize max_precision) + : m_precision(max_precision) { } @@ -554,9 +554,9 @@ namespace xt using cache_type = std::vector; using cache_iterator = typename cache_type::const_iterator; - explicit printer(std::streamsize precision) - : real_printer(precision) - , imag_printer(precision) + explicit printer(std::streamsize max_precision) + : real_printer(max_precision) + , imag_printer(max_precision) { } diff --git a/include/xtensor/misc/xsort.hpp b/include/xtensor/misc/xsort.hpp index 196ec45cd..619bbb6de 100644 --- a/include/xtensor/misc/xsort.hpp +++ b/include/xtensor/misc/xsort.hpp @@ -294,7 +294,7 @@ namespace xt template inline void argsort_iter( ConstRandomIt data_begin, - ConstRandomIt data_end, + [[maybe_unused]] ConstRandomIt data_end, RandomIt idx_begin, RandomIt idx_end, Compare comp, @@ -303,7 +303,6 @@ namespace xt { XTENSOR_ASSERT(std::distance(data_begin, data_end) >= 0); XTENSOR_ASSERT(std::distance(idx_begin, idx_end) == std::distance(data_begin, data_end)); - (void) idx_end; // TODO(C++17) [[maybe_unused]] only used in assertion. std::iota(idx_begin, idx_end, 0); switch (method) @@ -1237,7 +1236,6 @@ namespace xt template inline auto argmin(const xexpression& e) { - using value_type = typename E::value_type; auto&& ed = eval(e.derived_cast()); auto begin = ed.template begin(); auto end = ed.template end(); @@ -1267,7 +1265,6 @@ namespace xt template inline auto argmax(const xexpression& e) { - using value_type = typename E::value_type; auto&& ed = eval(e.derived_cast()); auto begin = ed.template begin(); auto end = ed.template end(); diff --git a/include/xtensor/optional/xoptional.hpp b/include/xtensor/optional/xoptional.hpp index 6c690b0d6..38c870e54 100644 --- a/include/xtensor/optional/xoptional.hpp +++ b/include/xtensor/optional/xoptional.hpp @@ -199,7 +199,7 @@ namespace xt template constexpr result_type apply_impl(const U& t, const Args&... args) const { - return t & apply_impl(args...); + return t && apply_impl(args...); } template @@ -242,7 +242,6 @@ namespace xt struct xreducer_temporary_type> { using type = xtl::xoptional, bool>; - ; }; } diff --git a/include/xtensor/reducers/xreducer.hpp b/include/xtensor/reducers/xreducer.hpp index e99522b5e..2c292eb9d 100644 --- a/include/xtensor/reducers/xreducer.hpp +++ b/include/xtensor/reducers/xreducer.hpp @@ -1552,7 +1552,7 @@ namespace xt inline auto xreducer::element(It first, It last) const -> const_reference { XTENSOR_TRY(check_element_index(shape(), first, last)); - auto stepper = const_stepper(*this, 0); + auto reducer_stepper = const_stepper(*this, 0); if (first != last) { size_type dim = 0; @@ -1563,16 +1563,16 @@ namespace xt { if (begin < first) { - stepper.step(dim++, std::size_t(0)); + reducer_stepper.step(dim++, std::size_t(0)); begin++; } else { - stepper.step(dim++, std::size_t(*begin++)); + reducer_stepper.step(dim++, std::size_t(*begin++)); } } } - return *stepper; + return *reducer_stepper; } /** diff --git a/include/xtensor/utils/xexception.hpp b/include/xtensor/utils/xexception.hpp index 025836ce2..c9c7ee51f 100644 --- a/include/xtensor/utils/xexception.hpp +++ b/include/xtensor/utils/xexception.hpp @@ -310,17 +310,18 @@ namespace xt #if (defined(XTENSOR_ENABLE_ASSERT) && !defined(XTENSOR_DISABLE_EXCEPTIONS)) #define XTENSOR_TRY(expr) XTENSOR_TRY_IMPL(expr, __FILE__, __LINE__) -#define XTENSOR_TRY_IMPL(expr, file, line) \ - try \ - { \ - expr; \ - } \ - catch (std::exception & e) \ - { \ - XTENSOR_THROW( \ - std::runtime_error, \ - std::string(file) + ':' + std::to_string(line) + ": check failed\n\t" + std::string(e.what()) \ - ); \ +#define XTENSOR_TRY_IMPL(expr, file, line) \ + try \ + { \ + expr; \ + } \ + catch (std::exception & xtensor_check_error) \ + { \ + XTENSOR_THROW( \ + std::runtime_error, \ + std::string(file) + ':' + std::to_string(line) + ": check failed\n\t" \ + + std::string(xtensor_check_error.what()) \ + ); \ } #else #define XTENSOR_TRY(expr) diff --git a/include/xtensor/utils/xutils.hpp b/include/xtensor/utils/xutils.hpp index ed4a04f48..943dd0e77 100644 --- a/include/xtensor/utils/xutils.hpp +++ b/include/xtensor/utils/xutils.hpp @@ -193,11 +193,7 @@ namespace xt ) { R res = init; - auto wrapper = [&](const auto& i, const auto& j) - { - res = f(i, j); - }; - (wrapper(res, std::get(t)), ...); + ((res = f(res, std::get(t))), ...); return res; } } diff --git a/include/xtensor/views/index_mapper.hpp b/include/xtensor/views/index_mapper.hpp index d445ac1ec..a3d4288de 100644 --- a/include/xtensor/views/index_mapper.hpp +++ b/include/xtensor/views/index_mapper.hpp @@ -18,7 +18,7 @@ namespace xt { template - struct index_mapper; + class index_mapper; /** * @enum access_t diff --git a/include/xtensor/views/xdynamic_view.hpp b/include/xtensor/views/xdynamic_view.hpp index 777ec66d3..7eb7d85b6 100644 --- a/include/xtensor/views/xdynamic_view.hpp +++ b/include/xtensor/views/xdynamic_view.hpp @@ -150,10 +150,10 @@ namespace xt template xdynamic_view( CTA&& e, - SA&& shape, - get_strides_t&& strides, + SA&& view_shape, + get_strides_t&& view_strides, std::size_t offset, - layout_type layout, + layout_type view_layout, slice_vector_type&& slices, get_strides_t&& adj_strides ) noexcept; @@ -225,14 +225,14 @@ namespace xt void fill(const T& value); template - stepper stepper_begin(const ST& shape); + stepper stepper_begin(const ST& iteration_shape); template - stepper stepper_end(const ST& shape, layout_type l); + stepper stepper_end(const ST& iteration_shape, layout_type l); template - const_stepper stepper_begin(const ST& shape) const; + const_stepper stepper_begin(const ST& iteration_shape) const; template - const_stepper stepper_end(const ST& shape, layout_type l) const; + const_stepper stepper_end(const ST& iteration_shape, layout_type l) const; using container_iterator = std:: conditional_t; @@ -383,14 +383,14 @@ namespace xt template inline xdynamic_view::xdynamic_view( CTA&& e, - SA&& shape, - get_strides_t&& strides, + SA&& view_shape, + get_strides_t&& view_strides, std::size_t offset, - layout_type layout, + layout_type view_layout, slice_vector_type&& slices, get_strides_t&& adj_strides ) noexcept - : base_type(std::forward(e), std::forward(shape), std::move(strides), offset, layout) + : base_type(std::forward(e), std::forward(view_shape), std::move(view_strides), offset, view_layout) , m_slices(std::move(slices)) , m_adj_strides(std::move(adj_strides)) { @@ -525,34 +525,35 @@ namespace xt template template - inline auto xdynamic_view::stepper_begin(const ST& shape) -> stepper + inline auto xdynamic_view::stepper_begin(const ST& iteration_shape) -> stepper { - size_type offset = shape.size() - dimension(); + size_type offset = iteration_shape.size() - dimension(); return stepper(this, offset); } template template - inline auto xdynamic_view::stepper_end(const ST& shape, layout_type /*l*/) -> stepper + inline auto xdynamic_view::stepper_end(const ST& iteration_shape, layout_type /*l*/) + -> stepper { - size_type offset = shape.size() - dimension(); + size_type offset = iteration_shape.size() - dimension(); return stepper(this, offset, true); } template template - inline auto xdynamic_view::stepper_begin(const ST& shape) const -> const_stepper + inline auto xdynamic_view::stepper_begin(const ST& iteration_shape) const -> const_stepper { - size_type offset = shape.size() - dimension(); + size_type offset = iteration_shape.size() - dimension(); return const_stepper(this, offset); } template template - inline auto xdynamic_view::stepper_end(const ST& shape, layout_type /*l*/) const + inline auto xdynamic_view::stepper_end(const ST& iteration_shape, layout_type /*l*/) const -> const_stepper { - size_type offset = shape.size() - dimension(); + size_type offset = iteration_shape.size() - dimension(); return const_stepper(this, offset, true); } diff --git a/include/xtensor/views/xslice.hpp b/include/xtensor/views/xslice.hpp index 6cd2865a4..c1ac83bb2 100644 --- a/include/xtensor/views/xslice.hpp +++ b/include/xtensor/views/xslice.hpp @@ -1301,9 +1301,9 @@ namespace xt t.begin(), t.end(), m_raw_indices.begin(), - [](auto t) + [](auto index) { - return static_cast(t); + return static_cast(index); } ); } @@ -1445,9 +1445,9 @@ namespace xt t.begin(), t.end(), m_raw_indices.begin(), - [](auto t) + [](auto index) { - return static_cast(t); + return static_cast(index); } ); } diff --git a/include/xtensor/views/xstrided_view.hpp b/include/xtensor/views/xstrided_view.hpp index b0fe2c6e0..f2deef640 100644 --- a/include/xtensor/views/xstrided_view.hpp +++ b/include/xtensor/views/xstrided_view.hpp @@ -188,7 +188,13 @@ namespace xt decltype(std::declval()[0])>; template - xstrided_view(CTA&& e, SA&& shape, strides_type&& strides, std::size_t offset, layout_type layout) noexcept; + xstrided_view( + CTA&& e, + SA&& view_shape, + strides_type&& view_strides, + std::size_t offset, + layout_type view_layout + ) noexcept; xstrided_view(const xstrided_view& rhs) = default; @@ -239,24 +245,24 @@ namespace xt const_reverse_linear_iterator linear_crend() const; template - disable_indexed_stepper_t stepper_begin(const ST& shape); + disable_indexed_stepper_t stepper_begin(const ST& iteration_shape); template - disable_indexed_stepper_t stepper_end(const ST& shape, layout_type l); + disable_indexed_stepper_t stepper_end(const ST& iteration_shape, layout_type l); template - enable_indexed_stepper_t stepper_begin(const ST& shape); + enable_indexed_stepper_t stepper_begin(const ST& iteration_shape); template - enable_indexed_stepper_t stepper_end(const ST& shape, layout_type l); + enable_indexed_stepper_t stepper_end(const ST& iteration_shape, layout_type l); template - disable_indexed_stepper_t stepper_begin(const ST& shape) const; + disable_indexed_stepper_t stepper_begin(const ST& iteration_shape) const; template - disable_indexed_stepper_t stepper_end(const ST& shape, layout_type l) const; + disable_indexed_stepper_t stepper_end(const ST& iteration_shape, layout_type l) const; template - enable_indexed_stepper_t stepper_begin(const ST& shape) const; + enable_indexed_stepper_t stepper_begin(const ST& iteration_shape) const; template - enable_indexed_stepper_t stepper_end(const ST& shape, layout_type l) const; + enable_indexed_stepper_t stepper_end(const ST& iteration_shape, layout_type l) const; template using simd_return_type = xt_simd::simd_return_type; @@ -363,21 +369,21 @@ namespace xt * Constructs an xstrided_view * * @param e the underlying xexpression for this view - * @param shape the shape of the view - * @param strides the strides of the view + * @param view_shape the shape of the view + * @param view_strides the strides of the view * @param offset the offset of the first element in the underlying container - * @param layout the layout of the view + * @param view_layout the layout of the view */ template template inline xstrided_view::xstrided_view( CTA&& e, - SA&& shape, - strides_type&& strides, + SA&& view_shape, + strides_type&& view_strides, std::size_t offset, - layout_type layout + layout_type view_layout ) noexcept - : base_type(std::forward(e), std::forward(shape), std::move(strides), offset, layout) + : base_type(std::forward(e), std::forward(view_shape), std::move(view_strides), offset, view_layout) { } @@ -565,71 +571,73 @@ namespace xt template template - inline auto xstrided_view::stepper_begin(const ST& shape) -> disable_indexed_stepper_t + inline auto xstrided_view::stepper_begin(const ST& iteration_shape) + -> disable_indexed_stepper_t { - size_type offset = shape.size() - dimension(); + size_type offset = iteration_shape.size() - dimension(); return stepper(this, data_xbegin(), offset); } template template - inline auto xstrided_view::stepper_end(const ST& shape, layout_type l) + inline auto xstrided_view::stepper_end(const ST& iteration_shape, layout_type l) -> disable_indexed_stepper_t { - size_type offset = shape.size() - dimension(); + size_type offset = iteration_shape.size() - dimension(); return stepper(this, data_xend(l, offset), offset); } template template - inline auto xstrided_view::stepper_begin(const ST& shape) -> enable_indexed_stepper_t + inline auto xstrided_view::stepper_begin(const ST& iteration_shape) + -> enable_indexed_stepper_t { - size_type offset = shape.size() - dimension(); + size_type offset = iteration_shape.size() - dimension(); return stepper(this, offset); } template template - inline auto xstrided_view::stepper_end(const ST& shape, layout_type /*l*/) + inline auto xstrided_view::stepper_end(const ST& iteration_shape, layout_type /*l*/) -> enable_indexed_stepper_t { - size_type offset = shape.size() - dimension(); + size_type offset = iteration_shape.size() - dimension(); return stepper(this, offset, true); } template template - inline auto xstrided_view::stepper_begin(const ST& shape) const + inline auto xstrided_view::stepper_begin(const ST& iteration_shape) const -> disable_indexed_stepper_t { - size_type offset = shape.size() - dimension(); + size_type offset = iteration_shape.size() - dimension(); return const_stepper(this, data_xbegin(), offset); } template template - inline auto xstrided_view::stepper_end(const ST& shape, layout_type l) const + inline auto xstrided_view::stepper_end(const ST& iteration_shape, layout_type l) const -> disable_indexed_stepper_t { - size_type offset = shape.size() - dimension(); + size_type offset = iteration_shape.size() - dimension(); return const_stepper(this, data_xend(l, offset), offset); } template template - inline auto xstrided_view::stepper_begin(const ST& shape) const + inline auto xstrided_view::stepper_begin(const ST& iteration_shape) const -> enable_indexed_stepper_t { - size_type offset = shape.size() - dimension(); + size_type offset = iteration_shape.size() - dimension(); return const_stepper(this, offset); } template template - inline auto xstrided_view::stepper_end(const ST& shape, layout_type /*l*/) const + inline auto xstrided_view::stepper_end(const ST& iteration_shape, layout_type /*l*/) const -> enable_indexed_stepper_t { - size_type offset = shape.size() - dimension(); + size_type offset = iteration_shape.size() - dimension(); return const_stepper(this, offset, true); } diff --git a/test/test_xarray_adaptor.cpp b/test/test_xarray_adaptor.cpp index 5142386f8..7ffbc5c63 100644 --- a/test/test_xarray_adaptor.cpp +++ b/test/test_xarray_adaptor.cpp @@ -191,7 +191,6 @@ namespace xt TEST(xarray_adaptor, iterator_types) { - using vec_type = std::vector; using array_type = xarray_adaptor; using const_array_type = xarray_adaptor; using iterator = vec_type::iterator; diff --git a/test/test_xbuffer_adaptor.cpp b/test/test_xbuffer_adaptor.cpp index 5b0a5fcb6..018870227 100644 --- a/test/test_xbuffer_adaptor.cpp +++ b/test/test_xbuffer_adaptor.cpp @@ -95,14 +95,14 @@ namespace xt TEST(xbuffer_adaptor, owner_move_assign_check_size) { size_check_allocator custom_allocator; - using owner_adaptor = xbuffer_adaptor; + using size_checked_adaptor = xbuffer_adaptor; size_t size1 = 100; size_t* data1 = custom_allocator.allocate(size1); - owner_adaptor adapt1(data1, size1); + size_checked_adaptor adapt1(data1, size1); size_t size2 = 200; size_t* data2 = custom_allocator.allocate(size2); - owner_adaptor adapt2(data2, size2); + size_checked_adaptor adapt2(data2, size2); adapt1 = adapt2; EXPECT_EQ(adapt1.size(), size2); diff --git a/test/test_xcomplex.cpp b/test/test_xcomplex.cpp index 920d21b8e..2281b0c3e 100644 --- a/test/test_xcomplex.cpp +++ b/test/test_xcomplex.cpp @@ -137,6 +137,8 @@ namespace xt #if XTENSOR_USE_XSIMD EXPECT_TRUE(assign_t_angle::simd_linear_assign()); +#else + EXPECT_FALSE(assign_t_angle::simd_linear_assign()); #endif auto cmplres_conj = xt::conj(cmplarg_0); @@ -155,6 +157,8 @@ namespace xt static_cast(b1); static_cast(b2); EXPECT_TRUE(assign_t_conj::simd_linear_assign()); +#else + EXPECT_FALSE(assign_t_conj::simd_linear_assign()); #endif auto cmplres_norm = xt::norm(cmplarg_0); @@ -168,6 +172,8 @@ namespace xt #if XTENSOR_USE_XSIMD EXPECT_TRUE(assign_t_norm::simd_linear_assign()); +#else + EXPECT_FALSE(assign_t_norm::simd_linear_assign()); #endif EXPECT_TRUE(allclose(fieldnorm, cmplres_norm)); @@ -196,6 +202,8 @@ namespace xt #if XTENSOR_USE_XSIMD EXPECT_TRUE(assign_t_arg::simd_linear_assign()); +#else + EXPECT_FALSE(assign_t_arg::simd_linear_assign()); #endif } diff --git a/test/test_xexpression.cpp b/test/test_xexpression.cpp index 75eba3edb..9eefdde39 100644 --- a/test/test_xexpression.cpp +++ b/test/test_xexpression.cpp @@ -102,13 +102,15 @@ namespace xt buffer << expr1; EXPECT_EQ(buffer.str(), "{{ 2., 4., 6., 8.},\n { 10., 12., 14., 16.}}"); - // Compilation test + // An xfunction has no strides of its own, so the shared expression + // derives all its strides types from its shape type. auto sexpr1 = make_xshared(std::move(expr1)); using expr_type = decltype(sexpr1); - using strides_type = typename expr_type::strides_type; - using inner_strides_type = typename expr_type::inner_strides_type; - using backstrides_type = typename expr_type::backstrides_type; - using inner_strides_tybackstrides_typepe = typename expr_type::inner_backstrides_type; + using expected_strides_type = get_strides_type::type; + EXPECT_TRUE((std::is_same::value)); + EXPECT_TRUE((std::is_same::value)); + EXPECT_TRUE((std::is_same::value)); + EXPECT_TRUE((std::is_same::value)); } TEST(xexpression, shared_expr_return) diff --git a/test/test_xexpression_holder.cpp b/test/test_xexpression_holder.cpp index cff5d6fb6..0bf4bfd24 100644 --- a/test/test_xexpression_holder.cpp +++ b/test/test_xexpression_holder.cpp @@ -24,7 +24,8 @@ namespace xt xexpression_holder holder_a = xexpression_holder(a); xexpression_holder holder_b(b); - xexpression_holder holder_c(std::move(xexpression_holder(c))); + xexpression_holder holder_tmp(c); + xexpression_holder holder_c(std::move(holder_tmp)); } TEST(xexpression_holder, assign) diff --git a/test/test_xmath.cpp b/test/test_xmath.cpp index 57771859b..982e71a1a 100644 --- a/test/test_xmath.cpp +++ b/test/test_xmath.cpp @@ -47,6 +47,8 @@ namespace xt #if XTENSOR_USE_XSIMD EXPECT_TRUE(assign_traits::simd_linear_assign()); +#else + EXPECT_FALSE(assign_traits::simd_linear_assign()); #endif } @@ -170,55 +172,55 @@ namespace xt TEST(xmath, minimum) { using opt_type = xoptional_assembly, xarray>; - auto missing = xtl::missing(); + auto missing_value = xtl::missing(); xarray a = {1, 2, 3, 4, 5, 6}; xarray b = {6, 5, 4, 3, 2, 1}; - opt_type opt_a = {1, missing, 3, 4, 5, missing}; - opt_type opt_b = {6, 5, 4, 3, missing, 1}; + opt_type opt_a = {1, missing_value, 3, 4, 5, missing_value}; + opt_type opt_b = {6, 5, 4, 3, missing_value, 1}; xarray res = {1, 2, 3, 3, 2, 1}; EXPECT_EQ(res, minimum(a, b)); - opt_type res1 = {1, missing, 3, 3, 2, missing}; + opt_type res1 = {1, missing_value, 3, 3, 2, missing_value}; EXPECT_EQ(res1, minimum(opt_a, b)); - opt_type res2 = {1, missing, 3, 3, missing, missing}; + opt_type res2 = {1, missing_value, 3, 3, missing_value, missing_value}; EXPECT_EQ(res2, minimum(opt_a, opt_b)); } TEST(xmath, maximum) { using opt_type = xoptional_assembly, xarray>; - auto missing = xtl::missing(); + auto missing_value = xtl::missing(); xarray a = {1, 2, 3, 4, 5, 6}; xarray b = {6, 5, 4, 3, 2, 1}; - opt_type opt_a = {1, missing, 3, 4, 5, missing}; - opt_type opt_b = {6, 5, 4, 3, missing, 1}; + opt_type opt_a = {1, missing_value, 3, 4, 5, missing_value}; + opt_type opt_b = {6, 5, 4, 3, missing_value, 1}; xarray res = {6, 5, 4, 4, 5, 6}; EXPECT_EQ(res, maximum(a, b)); - opt_type res1 = {6, missing, 4, 4, 5, missing}; + opt_type res1 = {6, missing_value, 4, 4, 5, missing_value}; EXPECT_EQ(res1, maximum(opt_a, b)); - opt_type res2 = {6, missing, 4, 4, missing, missing}; + opt_type res2 = {6, missing_value, 4, 4, missing_value, missing_value}; EXPECT_EQ(res2, maximum(opt_a, opt_b)); } TEST(xmath, clip) { using opt_type = xoptional_assembly, xarray>; - auto missing = xtl::missing(); + auto missing_value = xtl::missing(); xarray a = {1, 2, 3, 4, 5, 6}; - opt_type opt_a = {1, missing, 3, 4, 5, missing}; + opt_type opt_a = {1, missing_value, 3, 4, 5, missing_value}; xarray res = {2, 2, 3, 4, 4, 4}; EXPECT_EQ(res, clip(a, 2.0, 4.0)); - opt_type res1 = {2, missing, 3, 4, 4, missing}; + opt_type res1 = {2, missing_value, 3, 4, 4, missing_value}; EXPECT_EQ(res1, clip(opt_a, 2.0, 4.0)); } @@ -743,7 +745,7 @@ namespace xt EXPECT_EQ(math::abs(1ul), 1ul); EXPECT_EQ(math::abs(1u), 1u); EXPECT_EQ(math::abs(static_cast(1)), static_cast(1)); - EXPECT_EQ(math::abs(char(1)), 1); + EXPECT_EQ(math::abs(static_cast(-1)), 1); EXPECT_EQ(math::abs(int(1)), 1); EXPECT_EQ(math::abs(int(-1)), 1); EXPECT_EQ(math::abs(long(-1)), long(1)); diff --git a/test/test_xreducer.cpp b/test/test_xreducer.cpp index aa0a824b5..7fca4b51d 100644 --- a/test/test_xreducer.cpp +++ b/test/test_xreducer.cpp @@ -36,20 +36,20 @@ namespace xt #define CHECK_RESULT_TYPE(EXPRESSION, EXPECTED_TYPE) \ { \ - using result_type = typename std::decay_t::value_type; \ - EXPECT_TRUE((std::is_same::value)); \ + using actual_type = typename std::decay_t::value_type; \ + EXPECT_TRUE((std::is_same::value)); \ } #define CHECK_TAG_TYPE(EXPRESSION, EXPECTED_TYPE) \ { \ - using result_type = typename std::decay_t::expression_tag; \ - EXPECT_TRUE((std::is_same::value)); \ + using actual_type = typename std::decay_t::expression_tag; \ + EXPECT_TRUE((std::is_same::value)); \ } #define CHECK_TYPE(VALUE, EXPECTED_TYPE) \ { \ - using result_type = typename std::decay_t; \ - EXPECT_TRUE((std::is_same::value)); \ + using actual_type = typename std::decay_t; \ + EXPECT_TRUE((std::is_same::value)); \ } struct xreducer_features @@ -155,13 +155,13 @@ namespace xt #undef TEST_EXPRESSION_TAG -#define TEST_VALUE_HAS_VALUE(INPUT, V_TYPE, OPTIONAL) \ - using result_type = std::conditional_t, double>; \ - \ - auto res = xt::sum(INPUT, feats.m_axes); \ - CHECK_RESULT_TYPE(res, result_type); \ - CHECK_TYPE(xt::value(res)(1, 1, 1), V_TYPE); \ - EXPECT_EQ(!OPTIONAL, xt::has_value(res)(0, 0, 0)); \ +#define TEST_VALUE_HAS_VALUE(INPUT, V_TYPE, OPTIONAL) \ + using expected_type = std::conditional_t, double>; \ + \ + auto res = xt::sum(INPUT, feats.m_axes); \ + CHECK_RESULT_TYPE(res, expected_type); \ + CHECK_TYPE(xt::value(res)(1, 1, 1), V_TYPE); \ + EXPECT_EQ(!OPTIONAL, xt::has_value(res)(0, 0, 0)); \ EXPECT_TRUE(xt::has_value(res)(1, 1, 1)); TEST(xreducer, value_has_value) @@ -784,9 +784,9 @@ namespace xt { xtensor c = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}; auto xa = xt::sum(c, {0}, evaluation_strategy::immediate); - auto is_arr = [](const auto& c) + auto is_arr = [](const auto& shape) { - bool istrue = detail::is_array>::value; + bool istrue = detail::is_array>::value; return istrue; }; @@ -826,9 +826,9 @@ namespace xt b.resize({3, 3, 3}); std::iota(b.storage().begin(), b.storage().end(), 0); - auto is_arr = [](const auto& c) + auto is_arr = [](const auto& shape) { - bool istrue = detail::is_array>::value; + bool istrue = detail::is_array>::value; return istrue; }; diff --git a/test/test_xsort.cpp b/test/test_xsort.cpp index bbe928d4d..c8f9dc143 100644 --- a/test/test_xsort.cpp +++ b/test/test_xsort.cpp @@ -173,7 +173,7 @@ namespace xt 47, 41, 40, 34, 33, 43, 64 }; - EXPECT_EQ(ex, xt::argsort(a, {0}, xt::sorting_method::stable)); + EXPECT_EQ(ex, xt::argsort(a, 0, xt::sorting_method::stable)); } TEST(xsort, sort_easy) diff --git a/test/test_xstrided_view.cpp b/test/test_xstrided_view.cpp index b916d2473..8f7dbeffe 100644 --- a/test/test_xstrided_view.cpp +++ b/test/test_xstrided_view.cpp @@ -691,6 +691,8 @@ namespace xt #if XTENSOR_USE_XSIMD EXPECT_TRUE(assign_traits::simd_linear_assign()); +#else + EXPECT_FALSE(assign_traits::simd_linear_assign()); #endif EXPECT_EQ(av, e); diff --git a/test/test_xtensor_adaptor.cpp b/test/test_xtensor_adaptor.cpp index 5bbc5c0d3..a86d1da40 100644 --- a/test/test_xtensor_adaptor.cpp +++ b/test/test_xtensor_adaptor.cpp @@ -192,7 +192,6 @@ namespace xt TEST(xtensor_adaptor, iterator_types) { - using vec_type = std::vector; using tensor_type = xtensor_adaptor; using const_tensor_type = xtensor_adaptor; using iterator = vec_type::iterator; diff --git a/test/test_xview.cpp b/test/test_xview.cpp index 8069bb016..3d5478a84 100644 --- a/test/test_xview.cpp +++ b/test/test_xview.cpp @@ -1360,6 +1360,7 @@ namespace xt EXPECT_TRUE((detail::is_contiguous_view, xall, int, int>())); EXPECT_TRUE((detail::is_contiguous_view, xall, int, int>())); + EXPECT_FALSE((detail::is_contiguous_view, xall, int, int>())); EXPECT_FALSE((detail::is_contiguous_view, xall, int, int>())); EXPECT_TRUE((detail::is_contiguous_view, xall, xrange, int>())); EXPECT_FALSE((detail::is_contiguous_view, xrange, xrange, int>())); @@ -1477,13 +1478,12 @@ namespace xt #if XTENSOR_USE_XSIMD EXPECT_TRUE(assign_traits::simd_linear_assign()); +#else + EXPECT_FALSE(assign_traits::simd_linear_assign()); #endif using assign_traits2 = xassign_traits; - -#if XTENSOR_USE_XSIMD EXPECT_FALSE(assign_traits2::simd_linear_assign()); -#endif } }