boostorg / histogram

Fast multi-dimensional generalized histogram with convenient interface for C++14
Boost Software License 1.0
315 stars 72 forks source link

Variant axes and reduction #184

Closed henryiii closed 5 years ago

henryiii commented 5 years ago

The following code does not work:

std::vector<double> edges {{1.,2.,3.,4.,5.}};
using ax_vector = std::vector<axis::variant<axis::regular<>, axis::variable<>>>;

auto hist = make_histogram(ax_vector{axis::regular<>(10,0,1), axis::variable<>(edges)});
auto hist2 = algorithm::reduce(hist, algorithm::shrink(0, .3, .9));
// Error message:
// libc++abi.dylib: terminating with uncaught exception of type boost::wrapexcept<boost::bad_get>: boost::bad_get: failed value get using boost::get
// fish: './test/BoostHistogram-algorithm…' terminated by signal SIGABRT (Abort)

The non-variant version works.

I'm thinking it might be default-constructing the first item in the variant list, rather than matching the original axes?

HDembinski commented 5 years ago

I can reproduce the bug, working on it.

HDembinski commented 5 years ago

Found and fixed the problem. Currently waiting for the CI to test the code, then I will merge locally in my fork and push the changes to boostorg.

henryiii commented 5 years ago

Fantastic, thanks!

HDembinski commented 5 years ago

Thank you for finding and reporting this bug and the very nice minimal code example!