mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-11 05:07:58 +00:00
rename binary to boolean (#126)
This commit is contained in:
parent
4736fe761f
commit
5e60e86d3c
@ -38,6 +38,13 @@ install:
|
|||||||
- sh: rm -rf libs/histogram ; mv $APPVEYOR_BUILD_FOLDER libs/histogram
|
- sh: rm -rf libs/histogram ; mv $APPVEYOR_BUILD_FOLDER libs/histogram
|
||||||
- sh: python3 tools/boostdep/depinst/depinst.py --git_args "--depth 5 --jobs 2" histogram
|
- sh: python3 tools/boostdep/depinst/depinst.py --git_args "--depth 5 --jobs 2" histogram
|
||||||
|
|
||||||
|
# use hdembinski/serialization due to frequent errors in boostorg/serialization
|
||||||
|
- cd libs/serialization
|
||||||
|
- git remote add patch https://github.com/HDembinski/serialization.git
|
||||||
|
- git fetch patch
|
||||||
|
- git checkout patch/boost_histogram
|
||||||
|
- cd ../..
|
||||||
|
|
||||||
# prepare Boost build
|
# prepare Boost build
|
||||||
- cmd: cmd /c bootstrap & b2 headers & cd libs\histogram
|
- cmd: cmd /c bootstrap & b2 headers & cd libs\histogram
|
||||||
- sh: ./bootstrap.sh; ./b2 headers; cd libs/histogram
|
- sh: ./bootstrap.sh; ./b2 headers; cd libs/histogram
|
||||||
|
@ -68,6 +68,13 @@ matrix:
|
|||||||
- mv $TRAVIS_BUILD_DIR libs/histogram
|
- mv $TRAVIS_BUILD_DIR libs/histogram
|
||||||
- python3 tools/boostdep/depinst/depinst.py --git_args "--depth 5 --jobs 3" histogram
|
- python3 tools/boostdep/depinst/depinst.py --git_args "--depth 5 --jobs 3" histogram
|
||||||
|
|
||||||
|
# use hdembinski/serialization due to frequent errors in boostorg/serialization
|
||||||
|
- cd libs/serialization
|
||||||
|
- git remote add patch https://github.com/HDembinski/serialization.git
|
||||||
|
- git fetch patch
|
||||||
|
- git checkout patch/boost_histogram
|
||||||
|
- cd ../..
|
||||||
|
|
||||||
# prepare build
|
# prepare build
|
||||||
- ./bootstrap.sh
|
- ./bootstrap.sh
|
||||||
- ./b2 headers
|
- ./b2 headers
|
||||||
|
@ -57,8 +57,8 @@ static void category(benchmark::State& state) {
|
|||||||
for (auto _ : state) benchmark::DoNotOptimize(a.index(gen()));
|
for (auto _ : state) benchmark::DoNotOptimize(a.index(gen()));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void binary(benchmark::State& state) {
|
static void boolean(benchmark::State& state) {
|
||||||
auto a = axis::binary<>();
|
auto a = axis::boolean<>();
|
||||||
generator<uniform_int> gen(1);
|
generator<uniform_int> gen(1);
|
||||||
for (auto _ : state) benchmark::DoNotOptimize(a.index(static_cast<bool>(gen())));
|
for (auto _ : state) benchmark::DoNotOptimize(a.index(static_cast<bool>(gen())));
|
||||||
}
|
}
|
||||||
@ -74,4 +74,4 @@ BENCHMARK_TEMPLATE(integer, double, normal);
|
|||||||
BENCHMARK_TEMPLATE(variable, uniform)->RangeMultiplier(10)->Range(10, 10000);
|
BENCHMARK_TEMPLATE(variable, uniform)->RangeMultiplier(10)->Range(10, 10000);
|
||||||
BENCHMARK_TEMPLATE(variable, normal)->RangeMultiplier(10)->Range(10, 10000);
|
BENCHMARK_TEMPLATE(variable, normal)->RangeMultiplier(10)->Range(10, 10000);
|
||||||
BENCHMARK(category)->RangeMultiplier(10)->Range(10, 10000);
|
BENCHMARK(category)->RangeMultiplier(10)->Range(10, 10000);
|
||||||
BENCHMARK(binary);
|
BENCHMARK(boolean);
|
||||||
|
@ -20,9 +20,9 @@ int main() {
|
|||||||
using variable = axis::variable<>;
|
using variable = axis::variable<>;
|
||||||
using integer = axis::integer<>;
|
using integer = axis::integer<>;
|
||||||
using category = axis::category<>;
|
using category = axis::category<>;
|
||||||
using binary = axis::binary<>;
|
using boolean = axis::boolean<>;
|
||||||
using binary_no_metadata = axis::binary<axis::null_type>;
|
using boolean_no_metadata = axis::boolean<axis::null_type>;
|
||||||
using variant = axis::variant<regular, circular, variable, integer, category, binary>;
|
using variant = axis::variant<regular, circular, variable, integer, category, boolean>;
|
||||||
|
|
||||||
SHOW_SIZE(regular);
|
SHOW_SIZE(regular);
|
||||||
SHOW_SIZE(regular_float);
|
SHOW_SIZE(regular_float);
|
||||||
@ -32,7 +32,7 @@ int main() {
|
|||||||
SHOW_SIZE(variable);
|
SHOW_SIZE(variable);
|
||||||
SHOW_SIZE(integer);
|
SHOW_SIZE(integer);
|
||||||
SHOW_SIZE(category);
|
SHOW_SIZE(category);
|
||||||
SHOW_SIZE(binary);
|
SHOW_SIZE(boolean);
|
||||||
SHOW_SIZE(binary_no_metadata);
|
SHOW_SIZE(boolean_no_metadata);
|
||||||
SHOW_SIZE(variant);
|
SHOW_SIZE(variant);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ doxygen reference
|
|||||||
|
|
||||||
actions doxygen-postprocessing
|
actions doxygen-postprocessing
|
||||||
{
|
{
|
||||||
python $(THIS_PATH)/doxygen_postprocessing.py "$(>)"
|
python3 $(THIS_PATH)/doxygen_postprocessing.py "$(>)"
|
||||||
}
|
}
|
||||||
|
|
||||||
notfile reference-pp : @doxygen-postprocessing : reference.xml ;
|
notfile reference-pp : @doxygen-postprocessing : reference.xml ;
|
||||||
|
@ -123,6 +123,7 @@ An [*Axis] maps input values to indices. It holds state specific to that axis, l
|
|||||||
|
|
||||||
[heading Models]
|
[heading Models]
|
||||||
|
|
||||||
|
* [classref boost::histogram::axis::boolean]
|
||||||
* [classref boost::histogram::axis::category]
|
* [classref boost::histogram::axis::category]
|
||||||
* [classref boost::histogram::axis::integer]
|
* [classref boost::histogram::axis::integer]
|
||||||
* [classref boost::histogram::axis::regular]
|
* [classref boost::histogram::axis::regular]
|
||||||
|
@ -66,6 +66,14 @@ The library provides a number of useful axis types. The builtin axis types can b
|
|||||||
Axis over an integer sequence [i, i+1, i+2, ...]. It can be configured to handle real input values, too, and then acts like a fast regular axis with a fixed bin width of 1. Value-to-index conversion is O(1) and faster than for the [classref boost::histogram::axis::regular regular] axis. Does not allocate memory dynamically. Use this when your input consists of an integer range or pre-digitized values with low dynamic range, like pixel values for individual colours in an image.
|
Axis over an integer sequence [i, i+1, i+2, ...]. It can be configured to handle real input values, too, and then acts like a fast regular axis with a fixed bin width of 1. Value-to-index conversion is O(1) and faster than for the [classref boost::histogram::axis::regular regular] axis. Does not allocate memory dynamically. Use this when your input consists of an integer range or pre-digitized values with low dynamic range, like pixel values for individual colours in an image.
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
[
|
||||||
|
[
|
||||||
|
[classref boost::histogram::axis::boolean boolean]
|
||||||
|
]
|
||||||
|
[
|
||||||
|
Axis over the two values [false, true]. It is a common specialization of the [classref boost::histogram::axis::regular regular] axis. Value-to-index conversion is a pass-through operation, so this is the fastest possible axis. The axis has no state other than the metadata (which can be stateless). Does not allocate memory dynamically. Use this when your input consists of binary categories, like signal and background.
|
||||||
|
]
|
||||||
|
]
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
[classref boost::histogram::axis::category category]
|
[classref boost::histogram::axis::category category]
|
||||||
@ -341,7 +349,7 @@ boost::histogram::histogram<
|
|||||||
, boost::histogram::default_storage
|
, boost::histogram::default_storage
|
||||||
>
|
>
|
||||||
```
|
```
|
||||||
* Histogram with variable axis types:
|
* Histogram with variable axis types:
|
||||||
```
|
```
|
||||||
boost::histogram::histogram<
|
boost::histogram::histogram<
|
||||||
std::vector<
|
std::vector<
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
[1]: histogram/reference.html#header.boost.histogram.axis.ostream_hpp
|
[1]: histogram/reference.html#header.boost.histogram.axis.ostream_hpp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <boost/histogram/axis/binary.hpp>
|
#include <boost/histogram/axis/boolean.hpp>
|
||||||
#include <boost/histogram/axis/category.hpp>
|
#include <boost/histogram/axis/category.hpp>
|
||||||
#include <boost/histogram/axis/integer.hpp>
|
#include <boost/histogram/axis/integer.hpp>
|
||||||
#include <boost/histogram/axis/regular.hpp>
|
#include <boost/histogram/axis/regular.hpp>
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
// (See accompanying file LICENSE_1_0.txt
|
// (See accompanying file LICENSE_1_0.txt
|
||||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef BOOST_HISTOGRAM_AXIS_BINARY_HPP
|
#ifndef BOOST_HISTOGRAM_AXIS_BOOLEAN_HPP
|
||||||
#define BOOST_HISTOGRAM_AXIS_BINARY_HPP
|
#define BOOST_HISTOGRAM_AXIS_BOOLEAN_HPP
|
||||||
|
|
||||||
#include <boost/core/nvp.hpp>
|
#include <boost/core/nvp.hpp>
|
||||||
#include <boost/histogram/axis/iterator.hpp>
|
#include <boost/histogram/axis/iterator.hpp>
|
||||||
@ -20,13 +20,14 @@ namespace histogram {
|
|||||||
namespace axis {
|
namespace axis {
|
||||||
|
|
||||||
template <class MetaData>
|
template <class MetaData>
|
||||||
class binary : public iterator_mixin<binary<MetaData>>, public metadata_base_t<MetaData> {
|
class boolean : public iterator_mixin<boolean<MetaData>>,
|
||||||
|
public metadata_base_t<MetaData> {
|
||||||
using value_type = bool;
|
using value_type = bool;
|
||||||
using metadata_base = metadata_base_t<MetaData>;
|
using metadata_base = metadata_base_t<MetaData>;
|
||||||
using metadata_type = typename metadata_base::metadata_type;
|
using metadata_type = typename metadata_base::metadata_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit binary(metadata_type meta = {}) : metadata_base(std::move(meta)) {}
|
explicit boolean(metadata_type meta = {}) : metadata_base(std::move(meta)) {}
|
||||||
|
|
||||||
index_type index(value_type x) const noexcept { return static_cast<index_type>(x); }
|
index_type index(value_type x) const noexcept { return static_cast<index_type>(x); }
|
||||||
|
|
||||||
@ -39,12 +40,12 @@ public:
|
|||||||
static constexpr bool inclusive() noexcept { return true; }
|
static constexpr bool inclusive() noexcept { return true; }
|
||||||
|
|
||||||
template <class M>
|
template <class M>
|
||||||
bool operator==(const binary<M>& o) const noexcept {
|
bool operator==(const boolean<M>& o) const noexcept {
|
||||||
return detail::relaxed_equal{}(this->metadata(), o.metadata());
|
return detail::relaxed_equal{}(this->metadata(), o.metadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class M>
|
template <class M>
|
||||||
bool operator!=(const binary<M>& o) const noexcept {
|
bool operator!=(const boolean<M>& o) const noexcept {
|
||||||
return !operator==(o);
|
return !operator==(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,15 +56,15 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
template <class M>
|
template <class M>
|
||||||
friend class binary;
|
friend class boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if __cpp_deduction_guides >= 201606
|
#if __cpp_deduction_guides >= 201606
|
||||||
|
|
||||||
binary()->binary<null_type>;
|
boolean()->boolean<null_type>;
|
||||||
|
|
||||||
template <class M>
|
template <class M>
|
||||||
binary(M)->binary<detail::replace_type<std::decay_t<M>, const char*, std::string>>;
|
boolean(M) -> boolean<detail::replace_type<std::decay_t<M>, const char*, std::string>>;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -71,4 +72,4 @@ binary(M)->binary<detail::replace_type<std::decay_t<M>, const char*, std::string
|
|||||||
} // namespace histogram
|
} // namespace histogram
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif // BOOST_HISTOGRAM_AXIS_BINARY_HPP
|
#endif // BOOST_HISTOGRAM_AXIS_BOOLEAN_HPP
|
@ -197,8 +197,9 @@ std::basic_ostream<Ts...>& operator<<(std::basic_ostream<Ts...>& os,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class... Ts, class M>
|
template <class... Ts, class M>
|
||||||
std::basic_ostream<Ts...>& operator<<(std::basic_ostream<Ts...>& os, const binary<M>& a) {
|
std::basic_ostream<Ts...>& operator<<(std::basic_ostream<Ts...>& os,
|
||||||
os << "binary(";
|
const boolean<M>& a) {
|
||||||
|
os << "boolean(";
|
||||||
detail::ostream_metadata(os, a.metadata(), "");
|
detail::ostream_metadata(os, a.metadata(), "");
|
||||||
return os << ")";
|
return os << ")";
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ template <class Value = int, class MetaData = use_default, class Options = use_d
|
|||||||
class category;
|
class category;
|
||||||
|
|
||||||
template <class MetaData = use_default>
|
template <class MetaData = use_default>
|
||||||
class binary;
|
class boolean;
|
||||||
|
|
||||||
template <class... Ts>
|
template <class... Ts>
|
||||||
class variant;
|
class variant;
|
||||||
|
@ -51,7 +51,7 @@ boost_test(TYPE run SOURCES algorithm_project_test.cpp)
|
|||||||
boost_test(TYPE run SOURCES algorithm_reduce_test.cpp)
|
boost_test(TYPE run SOURCES algorithm_reduce_test.cpp)
|
||||||
boost_test(TYPE run SOURCES algorithm_sum_test.cpp)
|
boost_test(TYPE run SOURCES algorithm_sum_test.cpp)
|
||||||
boost_test(TYPE run SOURCES algorithm_empty_test.cpp)
|
boost_test(TYPE run SOURCES algorithm_empty_test.cpp)
|
||||||
boost_test(TYPE run SOURCES axis_binary_test.cpp)
|
boost_test(TYPE run SOURCES axis_boolean_test.cpp)
|
||||||
boost_test(TYPE run SOURCES axis_category_test.cpp)
|
boost_test(TYPE run SOURCES axis_category_test.cpp)
|
||||||
boost_test(TYPE run SOURCES axis_integer_test.cpp)
|
boost_test(TYPE run SOURCES axis_integer_test.cpp)
|
||||||
boost_test(TYPE run SOURCES axis_option_test.cpp)
|
boost_test(TYPE run SOURCES axis_option_test.cpp)
|
||||||
|
@ -52,7 +52,7 @@ alias cxx14 :
|
|||||||
[ run algorithm_reduce_test.cpp ]
|
[ run algorithm_reduce_test.cpp ]
|
||||||
[ run algorithm_sum_test.cpp ]
|
[ run algorithm_sum_test.cpp ]
|
||||||
[ run algorithm_empty_test.cpp ]
|
[ run algorithm_empty_test.cpp ]
|
||||||
[ run axis_binary_test.cpp ]
|
[ run axis_boolean_test.cpp ]
|
||||||
[ run axis_category_test.cpp ]
|
[ run axis_category_test.cpp ]
|
||||||
[ run axis_integer_test.cpp ]
|
[ run axis_integer_test.cpp ]
|
||||||
[ run axis_option_test.cpp ]
|
[ run axis_option_test.cpp ]
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/histogram/axis/binary.hpp>
|
#include <boost/histogram/axis/boolean.hpp>
|
||||||
#include <boost/histogram/axis/ostream.hpp>
|
#include <boost/histogram/axis/ostream.hpp>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -18,12 +18,12 @@
|
|||||||
int main() {
|
int main() {
|
||||||
using namespace boost::histogram;
|
using namespace boost::histogram;
|
||||||
|
|
||||||
BOOST_TEST(std::is_nothrow_move_assignable<axis::binary<>>::value);
|
BOOST_TEST(std::is_nothrow_move_assignable<axis::boolean<>>::value);
|
||||||
BOOST_TEST(std::is_nothrow_move_constructible<axis::binary<>>::value);
|
BOOST_TEST(std::is_nothrow_move_constructible<axis::boolean<>>::value);
|
||||||
|
|
||||||
// axis::integer with double type
|
// axis::integer with double type
|
||||||
{
|
{
|
||||||
axis::binary<> a{"foo"};
|
axis::boolean<> a{"foo"};
|
||||||
BOOST_TEST_EQ(a.metadata(), "foo");
|
BOOST_TEST_EQ(a.metadata(), "foo");
|
||||||
a.metadata() = "bar";
|
a.metadata() = "bar";
|
||||||
const auto& cref = a;
|
const auto& cref = a;
|
||||||
@ -36,24 +36,24 @@ int main() {
|
|||||||
BOOST_TEST_EQ(a.index(1), 1);
|
BOOST_TEST_EQ(a.index(1), 1);
|
||||||
BOOST_TEST_EQ(a.index(0), 0);
|
BOOST_TEST_EQ(a.index(0), 0);
|
||||||
|
|
||||||
BOOST_TEST_CSTR_EQ(str(a).c_str(), "binary(metadata=\"foo\")");
|
BOOST_TEST_CSTR_EQ(str(a).c_str(), "boolean(metadata=\"foo\")");
|
||||||
|
|
||||||
axis::binary<> b;
|
axis::boolean<> b;
|
||||||
BOOST_TEST_CSTR_EQ(str(b).c_str(), "binary()");
|
BOOST_TEST_CSTR_EQ(str(b).c_str(), "boolean()");
|
||||||
|
|
||||||
BOOST_TEST_NE(a, b);
|
BOOST_TEST_NE(a, b);
|
||||||
b = a;
|
b = a;
|
||||||
BOOST_TEST_EQ(a, b);
|
BOOST_TEST_EQ(a, b);
|
||||||
axis::binary<> c = std::move(b);
|
axis::boolean<> c = std::move(b);
|
||||||
BOOST_TEST_EQ(c, a);
|
BOOST_TEST_EQ(c, a);
|
||||||
axis::binary<> d;
|
axis::boolean<> d;
|
||||||
BOOST_TEST_NE(c, d);
|
BOOST_TEST_NE(c, d);
|
||||||
d = std::move(c);
|
d = std::move(c);
|
||||||
BOOST_TEST_EQ(d, a);
|
BOOST_TEST_EQ(d, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
// iterators
|
// iterators
|
||||||
test_axis_iterator(axis::binary<>(), 0, 2);
|
test_axis_iterator(axis::boolean<>(), 0, 2);
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
@ -129,7 +129,7 @@ int main() {
|
|||||||
test(axis::regular<>{2, -1, 1, "foo"},
|
test(axis::regular<>{2, -1, 1, "foo"},
|
||||||
"regular(2, -1, 1, metadata=\"foo\", options=underflow | overflow)");
|
"regular(2, -1, 1, metadata=\"foo\", options=underflow | overflow)");
|
||||||
|
|
||||||
test(axis::binary<>{"bar"}, "binary(metadata=\"bar\")");
|
test(axis::boolean<>{"bar"}, "boolean(metadata=\"bar\")");
|
||||||
|
|
||||||
struct user_defined {};
|
struct user_defined {};
|
||||||
const auto ref = "integer(-1, 1, metadata=" + detail::type_name<user_defined>() +
|
const auto ref = "integer(-1, 1, metadata=" + detail::type_name<user_defined>() +
|
||||||
@ -154,13 +154,13 @@ int main() {
|
|||||||
enum { A, B, C };
|
enum { A, B, C };
|
||||||
using variant =
|
using variant =
|
||||||
axis::variant<axis::regular<>, axis::regular<double, axis::transform::pow>,
|
axis::variant<axis::regular<>, axis::regular<double, axis::transform::pow>,
|
||||||
axis::category<>, axis::integer<>, axis::binary<>>;
|
axis::category<>, axis::integer<>, axis::boolean<>>;
|
||||||
std::vector<variant> axes;
|
std::vector<variant> axes;
|
||||||
axes.push_back(axis::regular<>{2, -1, 1});
|
axes.push_back(axis::regular<>{2, -1, 1});
|
||||||
axes.push_back(axis::regular<double, tr::pow>{tr::pow{0.5}, 2, 1, 4});
|
axes.push_back(axis::regular<double, tr::pow>{tr::pow{0.5}, 2, 1, 4});
|
||||||
axes.push_back(axis::category<>{A, B, C});
|
axes.push_back(axis::category<>{A, B, C});
|
||||||
axes.push_back(axis::integer<>{-1, 1});
|
axes.push_back(axis::integer<>{-1, 1});
|
||||||
axes.push_back(axis::binary<>{});
|
axes.push_back(axis::boolean<>{});
|
||||||
for (const auto& a : axes) {
|
for (const auto& a : axes) {
|
||||||
BOOST_TEST_NE(a, variant{});
|
BOOST_TEST_NE(a, variant{});
|
||||||
BOOST_TEST_EQ(a, variant(a));
|
BOOST_TEST_EQ(a, variant(a));
|
||||||
|
@ -85,9 +85,9 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
using axis::binary;
|
using axis::boolean;
|
||||||
BOOST_TEST_TRAIT_SAME(decltype(binary{}), binary<null_type>);
|
BOOST_TEST_TRAIT_SAME(decltype(boolean{}), boolean<null_type>);
|
||||||
BOOST_TEST_TRAIT_SAME(decltype(binary{"foo"}), binary<std::string>);
|
BOOST_TEST_TRAIT_SAME(decltype(boolean{"foo"}), boolean<std::string>);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user