mirror of
https://github.com/boostorg/histogram.git
synced 2026-01-29 19:42:12 +00:00
fixing a bug and adding a test for it
This commit is contained in:
@@ -122,10 +122,7 @@ public:
|
||||
inline int index(double x) const
|
||||
{
|
||||
const double z = (x - min_) / delta_;
|
||||
const int i = static_cast<int>(z);
|
||||
if (i > bins())
|
||||
return bins();
|
||||
return z >= 0.0 ? i : -1;
|
||||
return z < 0.0 ? -1 : (z > bins() ? bins() : static_cast<int>(z));
|
||||
}
|
||||
|
||||
double operator[](int idx) const
|
||||
|
||||
@@ -32,6 +32,8 @@ BOOST_AUTO_TEST_CASE(regular_axis_operators) {
|
||||
BOOST_CHECK_EQUAL(a.index(0.99), 2);
|
||||
BOOST_CHECK_EQUAL(a.index(1.0), 3);
|
||||
BOOST_CHECK_EQUAL(a.index(10.), 3);
|
||||
BOOST_CHECK_EQUAL(a.index(std::numeric_limits<double>::infinity()), 3);
|
||||
BOOST_CHECK_EQUAL(a.index(-std::numeric_limits<double>::infinity()), -1);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(polar_axis_operators) {
|
||||
|
||||
Reference in New Issue
Block a user