diff --git a/include/boost/histogram/detail/axes.hpp b/include/boost/histogram/detail/axes.hpp index e591ac7f..ff37df58 100644 --- a/include/boost/histogram/detail/axes.hpp +++ b/include/boost/histogram/detail/axes.hpp @@ -133,12 +133,12 @@ void axes_assign(dynamic_axes& t, const dynamic_axes& u) { } template -constexpr unsigned axes_size(const static_axes&) { +constexpr std::size_t axes_size(const static_axes&) { return sizeof...(Ts); } template -unsigned axes_size(const dynamic_axes& axes) { +std::size_t axes_size(const dynamic_axes& axes) { return axes.size(); } @@ -264,19 +264,25 @@ struct shape_collector { }; namespace { + template struct sub_axes_impl {}; template struct sub_axes_impl> { + static_assert(mp11::mp_is_set::value, + "integer arguments must be strictly ascending"); + static_assert(mp_last::value < sizeof...(Ts), "index out of range"); template using at = mp11::mp_at, I>; - using L = mp11::mp_rename, static_axes>; + using L = mp11::mp_rename; using type = mp11::mp_transform; }; template struct sub_axes_impl> { + static_assert(mp11::mp_is_set::value, + "integer arguments must be strictly ascending"); using type = dynamic_axes; }; } @@ -301,7 +307,7 @@ sub_axes, Ns...> make_sub_axes(const static_axes& t, N using T = static_axes; using U = sub_axes, Ns...>; U u; - using N1 = unique_sorted>; + using N1 = mp11::mp_list; using N2 = mp11::mp_iota>; using N3 = mp11::mp_transform; mp11::mp_for_each(sub_static_assign_impl{t, u}); @@ -323,9 +329,9 @@ struct sub_dynamic_assign_impl { template sub_axes, Ns...> make_sub_axes(const dynamic_axes& t, Ns...) { using T = dynamic_axes; - T u; + T u(t.get_allocator()); u.reserve(sizeof...(Ns)); - using N = unique_sorted>; + using N = mp11::mp_list; mp11::mp_for_each(sub_dynamic_assign_impl{t, u}); return u; } @@ -415,7 +421,7 @@ void args_to_index(optional_index& idx, const static_axes& axes, const U& const Us&... us) { const auto a_size = std::get(axes).size(); const auto a_shape = std::get(axes).shape(); - const int j = std::get(axes).index(u); + const auto j = std::get(axes).index(u); linearize(idx, a_size, a_shape, j); args_to_index<(D + 1)>(idx, axes, us...); } @@ -431,7 +437,7 @@ void args_to_index_iter(mp11::mp_size_t, optional_index& idx, const auto& a = axis_get(axes); const auto a_size = a.size(); const auto a_shape = a.shape(); - const int j = a.index(*iter); + const auto j = a.index(*iter); linearize(idx, a_size, a_shape, j); args_to_index_iter(mp11::mp_size_t<(N - 1)>(), idx, axes, ++iter); } @@ -446,7 +452,7 @@ void args_to_index_get(mp11::mp_size_t, optional_index& idx, constexpr std::size_t D = mp_size::value - N; const auto a_size = std::get(axes).size(); const auto a_shape = std::get(axes).shape(); - const int j = std::get(axes).index(std::get(t)); + const auto j = std::get(axes).index(std::get(t)); linearize(idx, a_size, a_shape, j); args_to_index_get(mp11::mp_size_t<(N - 1)>(), idx, axes, t); } diff --git a/include/boost/histogram/detail/meta.hpp b/include/boost/histogram/detail/meta.hpp index 5ecd5d0d..6d5ccffe 100644 --- a/include/boost/histogram/detail/meta.hpp +++ b/include/boost/histogram/detail/meta.hpp @@ -116,12 +116,12 @@ using copy_qualifiers = mp11::mp_if< template using mp_set_union = mp11::mp_apply_q, L>; -template -using unique_sorted = mp11::mp_unique>; - template using arg_type = mp11::mp_at_c, N>; +template +using mp_last = mp11::mp_at_c::value - 1)>; + } // namespace detail } // namespace histogram } // namespace boost diff --git a/include/boost/histogram/histogram.hpp b/include/boost/histogram/histogram.hpp index 37827b62..9f614ceb 100644 --- a/include/boost/histogram/histogram.hpp +++ b/include/boost/histogram/histogram.hpp @@ -97,12 +97,14 @@ public: } histogram& operator/=(const scale_type rhs) { + static_assert(std::is_floating_point::value, + "division requires a floating point type"); storage_ *= scale_type(1) / rhs; return *this; } /// Number of axes (dimensions) of histogram - unsigned dim() const noexcept { return detail::axes_size(axes_); } + std::size_t dim() const noexcept { return detail::axes_size(axes_); } /// Total number of bins in the histogram (including underflow/overflow) std::size_t size() const noexcept { return storage_.size(); } @@ -111,34 +113,36 @@ public: void reset() { storage_.reset(storage_.size()); } /// Get N-th axis (const version) - template - auto axis(mp11::mp_int) const -> const detail::axis_at& { + template + auto axis(mp11::mp_size_t) const -> const detail::axis_at& { detail::range_check(axes_); return detail::axis_get(axes_); } /// Get N-th axis - template - auto axis(mp11::mp_int) -> detail::axis_at& { + template + auto axis(mp11::mp_size_t) -> detail::axis_at& { detail::range_check(axes_); return detail::axis_get(axes_); } /// Get first axis (convenience for 1-d histograms, const version) - const detail::axis_at<0, axes_type>& axis() const { return axis(mp11::mp_int<0>()); } + const detail::axis_at<0, axes_type>& axis() const { return axis(mp11::mp_size_t<0>()); } /// Get first axis (convenience for 1-d histograms) - detail::axis_at<0, axes_type>& axis() { return axis(mp11::mp_int<0>()); } + detail::axis_at<0, axes_type>& axis() { return axis(mp11::mp_size_t<0>()); } /// Get N-th axis with runtime index (const version) template > - const detail::axis_at<0, U>& axis(int i) const { + const detail::axis_at<0, U>& axis(std::size_t i) const { + BOOST_ASSERT_MSG(i < axes_.size(), "index out of range"); return axes_[i]; } /// Get N-th axis with runtime index template > - detail::axis_at<0, U>& axis(int i) { + detail::axis_at<0, U>& axis(std::size_t i) { + BOOST_ASSERT_MSG(i < axes_.size(), "index out of range"); return axes_[i]; } @@ -200,14 +204,18 @@ public: } /// Returns a lower-dimensional histogram - template - auto reduce_to(mp11::mp_int, Ns...) const - -> histogram, Ns...>, storage_type> { - using sub_axes_type = detail::sub_axes, Ns...>; + // precondition: argument sequence must be strictly ascending axis indices + template + auto reduce_to(mp11::mp_size_t, Ns...) const + -> histogram, Ns...>, storage_type> { + using N = mp11::mp_size_t; + using LN = mp11::mp_list; + detail::range_check::value>(axes_); + using sub_axes_type = detail::sub_axes; using HR = histogram; - auto sub_axes = detail::make_sub_axes(axes_, mp11::mp_int(), Ns()...); + auto sub_axes = detail::make_sub_axes(axes_, N(), Ns()...); auto hr = HR(std::move(sub_axes), storage_type(storage_.get_allocator())); - const auto b = detail::bool_mask, Ns...>(dim(), true); + const auto b = detail::bool_mask(dim(), true); std::vector shape(dim()); for_each_axis(detail::shape_collector(shape.begin())); detail::index_mapper m(shape, b); @@ -215,7 +223,8 @@ public: return hr; } - // precondition: range represents sequence of strictly ascending axis indices + /// Returns a lower-dimensional histogram + // precondition: sequence must be strictly ascending axis indices template , typename = detail::requires_iterator> @@ -315,6 +324,7 @@ make_dynamic_histogram(Iterator begin, Iterator end) { return histogram_type(std::move(axes)); } +/// dynamic type factory from axis iterators with custom storage type template > histogram decltype(std::declval().axis(mp11::mp_int<0>())[0]) { - return histogram_.axis(mp11::mp_int<0>())[idx(0)]; + auto bin() const -> decltype(std::declval().axis()[0]) { + return histogram_.axis()[idx()]; } - template - auto bin(mp11::mp_int) const - -> decltype(std::declval().axis(mp11::mp_int())[0]) { - return histogram_.axis(mp11::mp_int())[idx(D)]; + template + auto bin(mp11::mp_size_t) const + -> decltype(std::declval().axis(mp11::mp_size_t())[0]) { + return histogram_.axis(mp11::mp_size_t())[idx(I)]; } template // use SFINAE for this method - auto bin(unsigned dim) const -> decltype(std::declval().axis(dim)[0]) { + auto bin(std::size_t dim) const -> decltype(std::declval().axis(dim)[0]) { return histogram_.axis(dim)[idx(dim)]; } diff --git a/include/boost/histogram/literals.hpp b/include/boost/histogram/literals.hpp index a9cb2d8e..bd71907b 100644 --- a/include/boost/histogram/literals.hpp +++ b/include/boost/histogram/literals.hpp @@ -8,6 +8,7 @@ #define _BOOST_HISTOGRAM_LITERALS_HPP_ #include +#include namespace boost { namespace histogram { @@ -17,59 +18,59 @@ template struct char2int; template <> struct char2int<'0'> { - static constexpr int value = 0; + static constexpr std::size_t value = 0; }; template <> struct char2int<'1'> { - static constexpr int value = 1; + static constexpr std::size_t value = 1; }; template <> struct char2int<'2'> { - static constexpr int value = 2; + static constexpr std::size_t value = 2; }; template <> struct char2int<'3'> { - static constexpr int value = 3; + static constexpr std::size_t value = 3; }; template <> struct char2int<'4'> { - static constexpr int value = 4; + static constexpr std::size_t value = 4; }; template <> struct char2int<'5'> { - static constexpr int value = 5; + static constexpr std::size_t value = 5; }; template <> struct char2int<'6'> { - static constexpr int value = 6; + static constexpr std::size_t value = 6; }; template <> struct char2int<'7'> { - static constexpr int value = 7; + static constexpr std::size_t value = 7; }; template <> struct char2int<'8'> { - static constexpr int value = 8; + static constexpr std::size_t value = 8; }; template <> struct char2int<'9'> { - static constexpr int value = 9; + static constexpr std::size_t value = 9; }; -template -constexpr int parse() { +template +constexpr std::size_t parse() { return N; } -template -constexpr int parse() { +template +constexpr std::size_t parse() { return parse::value, Rest...>(); } } // namespace detail template -auto operator"" _c() -> ::boost::mp11::mp_int()> { - return ::boost::mp11::mp_int()>(); +auto operator"" _c() -> ::boost::mp11::mp_size_t()> { + return ::boost::mp11::mp_size_t()>(); } } // namespace literals diff --git a/src/python/histogram.cpp b/src/python/histogram.cpp index 573588f7..5588349e 100644 --- a/src/python/histogram.cpp +++ b/src/python/histogram.cpp @@ -98,7 +98,7 @@ public: bp::list strides; auto& b = self.storage_.buffer_; d["typestr"] = bh::detail::apply(dtype_visitor(), b, shapes, strides); - for (unsigned i = 0; i < self.dim(); ++i) { + for (std::size_t i = 0; i < self.dim(); ++i) { if (i > 0) strides.append(strides[-1] * shapes[-1]); shapes.append(self.axis(i).shape()); } @@ -204,7 +204,7 @@ struct fetcher { template struct span { T* data; - unsigned size; + std::size_t size; const T* begin() const { return data; } const T* end() const { return data + size; } }; @@ -297,7 +297,7 @@ bp::object histogram_getitem(const pyhistogram& self, bp::object args) { } int idx[BOOST_HISTOGRAM_AXIS_LIMIT]; - for (unsigned i = 0; i < dim; ++i) idx[i] = bp::extract(args[i]); + for (std::size_t i = 0; i < dim; ++i) idx[i] = bp::extract(args[i]); return bp::object(self.at(span{idx, self.dim()})); } diff --git a/test/axis_test.cpp b/test/axis_test.cpp index 67cc0815..42dbd316 100644 --- a/test/axis_test.cpp +++ b/test/axis_test.cpp @@ -51,8 +51,7 @@ int main() { { axis::regular<> a{4, -2, 2}; BOOST_TEST_EQ(a[-1].lower(), -std::numeric_limits::infinity()); - BOOST_TEST_EQ(a[a.size()].upper(), - std::numeric_limits::infinity()); + BOOST_TEST_EQ(a[a.size()].upper(), std::numeric_limits::infinity()); axis::regular<> b; BOOST_TEST_NOT(a == b); b = a; @@ -150,8 +149,7 @@ int main() { { axis::variable<> a{-1, 0, 1}; BOOST_TEST_EQ(a[-1].lower(), -std::numeric_limits::infinity()); - BOOST_TEST_EQ(a[a.size()].upper(), - std::numeric_limits::infinity()); + BOOST_TEST_EQ(a[a.size()].upper(), std::numeric_limits::infinity()); axis::variable<> b; BOOST_TEST_NOT(a == b); b = a; @@ -235,10 +233,8 @@ int main() { // iterators { enum { A, B, C }; - test_axis_iterator(axis::regular<>(5, 0, 1, "", axis::uoflow_type::off), - 0, 5); - test_axis_iterator(axis::regular<>(5, 0, 1, "", axis::uoflow_type::on), 0, - 5); + test_axis_iterator(axis::regular<>(5, 0, 1, "", axis::uoflow_type::off), 0, 5); + test_axis_iterator(axis::regular<>(5, 0, 1, "", axis::uoflow_type::on), 0, 5); test_axis_iterator(axis::circular<>(5, 0, 1, ""), 0, 5); test_axis_iterator(axis::variable<>({1, 2, 3}, ""), 0, 2); test_axis_iterator(axis::integer<>(0, 4, ""), 0, 4); @@ -264,8 +260,7 @@ int main() { a6 = a1; BOOST_TEST_EQ(a6, a1); axis::any, axis::integer<>> a7(axis::integer<>(0, 2)); - BOOST_TEST_THROWS(axis::any> a8(a7), - std::invalid_argument); + BOOST_TEST_THROWS(axis::any> a8(a7), std::invalid_argument); BOOST_TEST_THROWS(a4 = a7, std::invalid_argument); } @@ -288,15 +283,14 @@ int main() { std::string b = "B"; std::vector axes; axes.push_back(axis::regular<>{2, -1, 1, "regular1"}); - axes.push_back(axis::regular( - 2, 1, 10, "regular2", axis::uoflow_type::off)); - axes.push_back(axis::regular( - 2, 1, 10, "regular3", axis::uoflow_type::on, 0.5)); - axes.push_back(axis::regular( - 2, 1, 10, "regular4", axis::uoflow_type::off, -0.5)); + axes.push_back(axis::regular(2, 1, 10, "regular2", + axis::uoflow_type::off)); + axes.push_back(axis::regular(2, 1, 10, "regular3", + axis::uoflow_type::on, 0.5)); + axes.push_back(axis::regular(2, 1, 10, "regular4", + axis::uoflow_type::off, -0.5)); axes.push_back(axis::circular<>(4, 0.1, 1.0, "polar")); - axes.push_back( - axis::variable<>({-1, 0, 1}, "variable", axis::uoflow_type::off)); + axes.push_back(axis::variable<>({-1, 0, 1}, "variable", axis::uoflow_type::off)); axes.push_back(axis::category<>({A, B, C}, "category")); axes.push_back(axis::category({a, b}, "category2")); axes.push_back(axis::integer<>(-1, 1, "integer", axis::uoflow_type::off)); @@ -322,8 +316,8 @@ int main() { enum { A, B, C }; std::vector axes; axes.push_back(axis::regular<>{2, -1, 1}); - axes.push_back(axis::regular( - 2, 1, 4, "", axis::uoflow_type::on, 0.5)); + axes.push_back( + axis::regular(2, 1, 4, "", axis::uoflow_type::on, 0.5)); axes.push_back(axis::circular<>{4}); axes.push_back(axis::variable<>{-1, 0, 1}); axes.push_back(axis::category<>{A, B, C}); @@ -348,13 +342,12 @@ int main() { // sequence equality { enum { A, B, C }; - std::vector, axis::variable<>, axis::category<>, - axis::integer<>>> + std::vector< + axis::any, axis::variable<>, axis::category<>, axis::integer<>>> std_vector1 = {axis::regular<>{2, -1, 1}, axis::variable<>{-1, 0, 1}, axis::category<>{A, B, C}}; - std::vector< - axis::any, axis::variable<>, axis::category<>>> + std::vector, axis::variable<>, axis::category<>>> std_vector2 = {axis::regular<>{2, -1, 1}, axis::variable<>{-1, 0, 1}, axis::category<>{{A, B, C}}}; @@ -368,16 +361,13 @@ int main() { BOOST_TEST_NOT(detail::axes_equal(std_vector2, std_vector3)); BOOST_TEST_NOT(detail::axes_equal(std_vector3, std_vector4)); - auto tuple1 = - std::make_tuple(axis::regular<>{2, -1, 1}, axis::variable<>{-1, 0, 1}, - axis::category<>{{A, B, C}}); + auto tuple1 = std::make_tuple(axis::regular<>{2, -1, 1}, axis::variable<>{-1, 0, 1}, + axis::category<>{{A, B, C}}); - auto tuple2 = - std::make_tuple(axis::regular<>{2, -1, 1}, axis::variable<>{-1, 0, 1}, - axis::category<>{{A, B}}); + auto tuple2 = std::make_tuple(axis::regular<>{2, -1, 1}, axis::variable<>{-1, 0, 1}, + axis::category<>{{A, B}}); - auto tuple3 = std::make_tuple(axis::regular<>{2, -1, 1}, - axis::variable<>{-1, 0, 1}); + auto tuple3 = std::make_tuple(axis::regular<>{2, -1, 1}, axis::variable<>{-1, 0, 1}); BOOST_TEST(detail::axes_equal(std_vector1, tuple1)); BOOST_TEST(detail::axes_equal(tuple1, std_vector1)); @@ -389,22 +379,20 @@ int main() { // sequence assign { enum { A, B, C, D }; - std::vector, axis::variable<>, axis::category<>, - axis::integer<>>> + std::vector< + axis::any, axis::variable<>, axis::category<>, axis::integer<>>> std_vector1 = {axis::regular<>{2, -1, 1}, axis::variable<>{-1, 0, 1}, axis::category<>{A, B, C}}; - std::vector< - axis::any, axis::variable<>, axis::category<>>> + std::vector, axis::variable<>, axis::category<>>> std_vector2 = {axis::regular<>{2, -2, 2}, axis::variable<>{-2, 0, 2}, axis::category<>{A, B}}; detail::axes_assign(std_vector2, std_vector1); BOOST_TEST(detail::axes_equal(std_vector2, std_vector1)); - auto tuple1 = - std::make_tuple(axis::regular<>{2, -3, 3}, axis::variable<>{-3, 0, 3}, - axis::category<>{A, B, C, D}); + auto tuple1 = std::make_tuple(axis::regular<>{2, -3, 3}, axis::variable<>{-3, 0, 3}, + axis::category<>{A, B, C, D}); detail::axes_assign(tuple1, std_vector1); BOOST_TEST(detail::axes_equal(tuple1, std_vector1)); @@ -414,9 +402,8 @@ int main() { detail::axes_assign(std_vector3, tuple1); BOOST_TEST(detail::axes_equal(std_vector3, tuple1)); - auto tuple2 = - std::make_tuple(axis::regular<>{2, -1, 1}, axis::variable<>{-1, 0, 1}, - axis::category<>{A, B}); + auto tuple2 = std::make_tuple(axis::regular<>{2, -1, 1}, axis::variable<>{-1, 0, 1}, + axis::category<>{A, B}); detail::axes_assign(tuple2, tuple1); BOOST_TEST(detail::axes_equal(tuple2, tuple1)); @@ -428,26 +415,17 @@ int main() { using ia = axis::integer<>; using ca = axis::category<>; using T = static_axes; + BOOST_TEST_TRAIT_TRUE((std::is_same, static_axes>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, static_axes>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, static_axes>)); BOOST_TEST_TRAIT_TRUE( - (std::is_same, static_axes>)); - BOOST_TEST_TRAIT_TRUE( - (std::is_same, static_axes>)); - BOOST_TEST_TRAIT_TRUE( - (std::is_same, static_axes>)); - BOOST_TEST_TRAIT_TRUE((std::is_same, - static_axes>)); - BOOST_TEST_TRAIT_TRUE((std::is_same, - static_axes>)); + (std::is_same, static_axes>)); BOOST_TEST_TRAIT_TRUE( (std::is_same, static_axes>)); BOOST_TEST_TRAIT_TRUE( (std::is_same, static_axes>)); BOOST_TEST_TRAIT_TRUE( - (std::is_same, static_axes>)); - BOOST_TEST_TRAIT_TRUE( - (std::is_same, static_axes>)); - BOOST_TEST_TRAIT_TRUE((std::is_same, - static_axes>)); + (std::is_same, static_axes>)); } // make_sub_tuple @@ -457,10 +435,9 @@ int main() { auto axes = T(ia(0, 1), ia(1, 2), ia(2, 3)); BOOST_TEST_EQ(detail::make_sub_axes(axes, i1(), i2()), (static_axes(ia(1, 2), ia(2, 3)))); - BOOST_TEST_EQ(detail::make_sub_axes(axes, i1(), i0()), + BOOST_TEST_EQ(detail::make_sub_axes(axes, i0(), i1()), (static_axes(ia(0, 1), ia(1, 2)))); - BOOST_TEST_EQ(detail::make_sub_axes(axes, i1(), i1()), - (static_axes(ia(1, 2)))); + BOOST_TEST_EQ(detail::make_sub_axes(axes, i1()), (static_axes(ia(1, 2)))); BOOST_TEST_EQ(detail::make_sub_axes(axes, i0(), i1(), i2()), axes); } diff --git a/test/fail_histogram_add_dynamic_test.cpp b/test/fail_histogram_dynamic_add_test.cpp similarity index 51% rename from test/fail_histogram_add_dynamic_test.cpp rename to test/fail_histogram_dynamic_add_test.cpp index 070666ba..741e6647 100644 --- a/test/fail_histogram_add_dynamic_test.cpp +++ b/test/fail_histogram_dynamic_add_test.cpp @@ -1,3 +1,9 @@ +// Copyright 2018 Hans Dembinski +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + #include using namespace boost::histogram; diff --git a/test/fail_histogram_dynamic_at_tuple_wrong_dimension_test.cpp b/test/fail_histogram_dynamic_at_tuple_wrong_dimension_test.cpp index c5389157..0ed96e26 100644 --- a/test/fail_histogram_dynamic_at_tuple_wrong_dimension_test.cpp +++ b/test/fail_histogram_dynamic_at_tuple_wrong_dimension_test.cpp @@ -1,3 +1,9 @@ +// Copyright 2018 Hans Dembinski +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + #include #include diff --git a/test/fail_histogram_dynamic_at_vector_wrong_dimension_test.cpp b/test/fail_histogram_dynamic_at_vector_wrong_dimension_test.cpp index bb5eb0bc..9c551867 100644 --- a/test/fail_histogram_dynamic_at_vector_wrong_dimension_test.cpp +++ b/test/fail_histogram_dynamic_at_vector_wrong_dimension_test.cpp @@ -1,3 +1,9 @@ +// Copyright 2018 Hans Dembinski +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + #include #include diff --git a/test/fail_histogram_dynamic_at_wrong_dimension_test.cpp b/test/fail_histogram_dynamic_at_wrong_dimension_test.cpp index c183aacb..49bd9902 100644 --- a/test/fail_histogram_dynamic_at_wrong_dimension_test.cpp +++ b/test/fail_histogram_dynamic_at_wrong_dimension_test.cpp @@ -1,3 +1,9 @@ +// Copyright 2018 Hans Dembinski +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + #include using namespace boost::histogram; diff --git a/test/fail_histogram_dynamic_reduce_wrong_order_test.cpp b/test/fail_histogram_dynamic_reduce_wrong_order_test.cpp new file mode 100644 index 00000000..201f5ccf --- /dev/null +++ b/test/fail_histogram_dynamic_reduce_wrong_order_test.cpp @@ -0,0 +1,14 @@ +// Copyright 2018 Hans Dembinski +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include + +using namespace boost::histogram; +int main() { + auto h = make_dynamic_histogram(axis::integer<>(0, 1), axis::integer<>(1, 2)); + auto v = {0, 0}; + h.reduce_to(v.begin(), v.end()); +} diff --git a/test/fail_histogram_add_static_test.cpp b/test/fail_histogram_static_add_test.cpp similarity index 51% rename from test/fail_histogram_add_static_test.cpp rename to test/fail_histogram_static_add_test.cpp index cff1ed26..7e73c286 100644 --- a/test/fail_histogram_add_static_test.cpp +++ b/test/fail_histogram_static_add_test.cpp @@ -1,3 +1,9 @@ +// Copyright 2018 Hans Dembinski +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + #include using namespace boost::histogram; diff --git a/test/fail_histogram_static_at_vector_wrong_dimension_test.cpp b/test/fail_histogram_static_at_vector_wrong_dimension_test.cpp index 276d1b2a..c425e536 100644 --- a/test/fail_histogram_static_at_vector_wrong_dimension_test.cpp +++ b/test/fail_histogram_static_at_vector_wrong_dimension_test.cpp @@ -1,3 +1,9 @@ +// Copyright 2018 Hans Dembinski +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + #include using namespace boost::histogram; diff --git a/test/meta_test.cpp b/test/meta_test.cpp index 7edce2ea..41e8abd0 100644 --- a/test/meta_test.cpp +++ b/test/meta_test.cpp @@ -109,17 +109,21 @@ int main() { // rm_cv_ref { using T1 = int; - using T2 = const int; - using T3 = const int&; - using T4 = volatile int; - using T5 = volatile const int; - using T6 = volatile const int&; + using T2 = int&&; + using T3 = const int; + using T4 = const int&; + using T5 = volatile int; + using T6 = volatile int&&; + using T7 = volatile const int; + using T8 = volatile const int&; BOOST_TEST_TRAIT_TRUE((std::is_same, int>)); BOOST_TEST_TRAIT_TRUE((std::is_same, int>)); BOOST_TEST_TRAIT_TRUE((std::is_same, int>)); BOOST_TEST_TRAIT_TRUE((std::is_same, int>)); BOOST_TEST_TRAIT_TRUE((std::is_same, int>)); BOOST_TEST_TRAIT_TRUE((std::is_same, int>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, int>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, int>)); } // mp_size @@ -152,14 +156,5 @@ int main() { BOOST_TEST_TRAIT_TRUE((std::is_same)); } - // unique_sorted - { - using input = mp11::mp_list_c; - using result = unique_sorted; - using expected = mp11::mp_list_c; - - BOOST_TEST_TRAIT_TRUE((std::is_same)); - } - return boost::report_errors(); } diff --git a/test/pass_on_fail.py b/test/pass_on_fail.py index 80f492f0..41a95cf0 100644 --- a/test/pass_on_fail.py +++ b/test/pass_on_fail.py @@ -1,3 +1,11 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2018 Hans Dembinski +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt +# or copy at http://www.boost.org/LICENSE_1_0.txt) + import subprocess as subp import sys import os diff --git a/test/speed_numpy.py b/test/speed_numpy.py index 745fc955..65215039 100644 --- a/test/speed_numpy.py +++ b/test/speed_numpy.py @@ -1,9 +1,10 @@ -## -## Copyright 2015-2016 Hans Dembinski -## -## Distributed under the Boost Software License, Version 1.0. -## (See accompanying file LICENSE_1_0.txt -## or copy at http://www.boost.org/LICENSE_1_0.txt) +# -*- coding: utf-8 -*- +# +# Copyright 2015-2016 Hans Dembinski +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt +# or copy at http://www.boost.org/LICENSE_1_0.txt) import numpy as np from timeit import default_timer as timer diff --git a/test/utility.hpp b/test/utility.hpp index 98051ef1..7a8fd9db 100644 --- a/test/utility.hpp +++ b/test/utility.hpp @@ -1,4 +1,4 @@ -// Copyright 2015-2017 Hans Dembinski +// Copyright 2018 Hans Dembinski // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt @@ -15,10 +15,10 @@ #include #include -using i0 = boost::mp11::mp_int<0>; -using i1 = boost::mp11::mp_int<1>; -using i2 = boost::mp11::mp_int<2>; -using i3 = boost::mp11::mp_int<3>; +using i0 = boost::mp11::mp_size_t<0>; +using i1 = boost::mp11::mp_size_t<1>; +using i2 = boost::mp11::mp_size_t<2>; +using i3 = boost::mp11::mp_size_t<3>; namespace std { // never add to std, we only do it to get ADL working template diff --git a/test/utility_test.cpp b/test/utility_test.cpp index 1f5e5115..c36b6fe2 100644 --- a/test/utility_test.cpp +++ b/test/utility_test.cpp @@ -1,4 +1,4 @@ -// Copyright 2015-2017 Hans Dembinski +// Copyright 2018 Hans Dembinski // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt