mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-09 23:04:07 +00:00
clean up
This commit is contained in:
parent
1f1eda5c97
commit
8f3a3c07e4
@ -345,61 +345,6 @@ void run_tests(const std::vector<int>& x, const std::vector<int>& y,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void special_tests() {
|
|
||||||
// 1D growing (bug?)
|
|
||||||
{
|
|
||||||
using axis_type_1 =
|
|
||||||
axis::regular<double, use_default, use_default, axis::option::bitset<11u>>;
|
|
||||||
using axis_type_2 = axis::regular<double>;
|
|
||||||
using axis_type_3 = axis::integer<int>;
|
|
||||||
using axis_type_4 = axis::category<int>;
|
|
||||||
using axis_type_5 = axis::category<std::string>;
|
|
||||||
|
|
||||||
using axis_variant_type =
|
|
||||||
axis::variant<axis_type_1, axis_type_2, axis_type_3, axis_type_4, axis_type_5>;
|
|
||||||
|
|
||||||
auto axes = std::vector<axis_variant_type>({axis_type_1(10, 0, 1)});
|
|
||||||
auto h = histogram<decltype(axes), dense_storage<double>>(axes);
|
|
||||||
auto h2 = h;
|
|
||||||
|
|
||||||
std::vector<int> f1({2});
|
|
||||||
std::vector<int> f2({-1});
|
|
||||||
|
|
||||||
h(2);
|
|
||||||
h(-1);
|
|
||||||
|
|
||||||
h2.fill(f1);
|
|
||||||
h2.fill(f2);
|
|
||||||
|
|
||||||
BOOST_TEST_EQ(h, h2);
|
|
||||||
BOOST_TEST_EQ(sum(h2), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1D growing (bug?)
|
|
||||||
{
|
|
||||||
using axis_type_1 =
|
|
||||||
axis::regular<double, use_default, use_default, axis::option::bitset<11u>>;
|
|
||||||
|
|
||||||
using axis_variant_type = axis::variant<axis_type_1>;
|
|
||||||
|
|
||||||
auto axes = std::vector<axis_variant_type>({axis_type_1(10, 0, 1)});
|
|
||||||
auto h = histogram<decltype(axes), dense_storage<double>>(axes);
|
|
||||||
auto h2 = h;
|
|
||||||
|
|
||||||
std::vector<int> f1({2});
|
|
||||||
std::vector<int> f2({-1});
|
|
||||||
|
|
||||||
h(2);
|
|
||||||
h(-1);
|
|
||||||
|
|
||||||
h2.fill(f1);
|
|
||||||
h2.fill(f2);
|
|
||||||
|
|
||||||
BOOST_TEST_EQ(h, h2);
|
|
||||||
BOOST_TEST_EQ(sum(h2), 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
std::mt19937 gen(1);
|
std::mt19937 gen(1);
|
||||||
std::normal_distribution<> id(0, 2);
|
std::normal_distribution<> id(0, 2);
|
||||||
@ -414,7 +359,5 @@ int main() {
|
|||||||
run_tests<static_tag>(x, y, w);
|
run_tests<static_tag>(x, y, w);
|
||||||
run_tests<dynamic_tag>(x, y, w);
|
run_tests<dynamic_tag>(x, y, w);
|
||||||
|
|
||||||
special_tests();
|
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,40 @@ using arg_t = boost::variant2::variant<std::vector<int>, int>;
|
|||||||
int main() {
|
int main() {
|
||||||
using axis_type =
|
using axis_type =
|
||||||
bh::axis::regular<double, bh::use_default, bh::use_default, uogrowth_t>;
|
bh::axis::regular<double, bh::use_default, bh::use_default, uogrowth_t>;
|
||||||
using axis_variant = bh::axis::variant<axis_type>;
|
using axis_variant_type = bh::axis::variant<axis_type>;
|
||||||
|
|
||||||
auto axes = std::vector<axis_variant>({axis_type(10, 0, 1)});
|
// 1D growing A
|
||||||
auto h = bh::make_histogram_with(std::vector<int>(), axes);
|
{
|
||||||
BOOST_TEST_EQ(h.rank(), 1);
|
auto axes = std::vector<axis_variant_type>({axis_type(10, 0, 1)});
|
||||||
|
auto h = bh::make_histogram_with(bh::dense_storage<double>(), axes);
|
||||||
|
auto h2 = h;
|
||||||
|
|
||||||
std::vector<arg_t> vargs = {-1};
|
h(-1);
|
||||||
h.fill(vargs); // CRASH, using h.fill(-1) or h.fill(args) does not crash.
|
|
||||||
|
// used to crash, while growing B did not crash
|
||||||
|
std::vector<arg_t> vargs = {-1};
|
||||||
|
h2.fill(vargs);
|
||||||
|
|
||||||
|
BOOST_TEST_EQ(h, h2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1D growing B
|
||||||
|
{
|
||||||
|
auto axes = std::vector<axis_variant_type>({axis_type(10, 0, 1)});
|
||||||
|
auto h = bh::make_histogram_with(bh::dense_storage<double>(), axes);
|
||||||
|
auto h2 = h;
|
||||||
|
|
||||||
|
h(2);
|
||||||
|
h(-1);
|
||||||
|
|
||||||
|
std::vector<int> f1({2});
|
||||||
|
std::vector<int> f2({-1});
|
||||||
|
|
||||||
|
h2.fill(f1);
|
||||||
|
h2.fill(f2);
|
||||||
|
|
||||||
|
BOOST_TEST_EQ(h, h2);
|
||||||
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user