boostorg / histogram

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

Creating category axis from empty sequence disallowed even if growth=true #252

Closed henryiii closed 4 years ago

henryiii commented 4 years ago

Currently, the check for bins does not take into account growth; this makes it impossible to create an empty category axis, for example. The check maybe should look like this instead:

if (size() == 0 && !options_type::test(option::growth))
    BOOST_THROW_EXCEPTION(std::invalid_argument("bins > 0 required unless growth is enabled"));

(Verified to work in a simple case)

HDembinski commented 4 years ago

It is possible to create an empty category axis, just use the default ctor, see axis_category_test.cpp:121.

Nevertheless, passing an empty sequence should be allowed, too, when growth is on, good catch.

henryiii commented 4 years ago

It's not possible to make an empty category axis with metadata, then, unless the metadata is set later.

HDembinski commented 4 years ago

See https://github.com/HDembinski/histogram/pull/81

HDembinski commented 4 years ago

fixed in develop