Skip to content

Commit 662aef3

Browse files
committed
fix: allow inf for get_rank
1 parent 99d06bf commit 662aef3

3 files changed

Lines changed: 0 additions & 16 deletions

File tree

tdigest/include/tdigest.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ class tdigest {
154154
* Compute approximate normalized rank of the given value.
155155
*
156156
* <p>If the sketch is empty this throws std::runtime_error.
157-
* <p>NaN and infinity values throw std::invalid_argument.
158157
*
159158
* @param value to be ranked
160159
* @return normalized rank (from 0 to 1 inclusive)

tdigest/include/tdigest_impl.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ template<typename T, typename A>
109109
double tdigest<T, A>::get_rank(T value) const {
110110
if (is_empty()) throw std::runtime_error("operation is undefined for an empty sketch");
111111
if (std::isnan(value)) throw std::invalid_argument("operation is undefined for NaN");
112-
if (std::isinf(value)) throw std::invalid_argument("operation is undefined for infinity");
113112
if (value < min_) return 0;
114113
if (value > max_) return 1;
115114
// one centroid and value == min_ == max_

tdigest/test/tdigest_test.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -510,20 +510,6 @@ TEST_CASE("update rejects negative infinity", "[tdigest]") {
510510
REQUIRE(td.get_min_value() == 1.0);
511511
}
512512

513-
TEST_CASE("get_rank rejects positive infinity", "[tdigest]") {
514-
tdigest_double td(100);
515-
td.update(1.0);
516-
td.update(2.0);
517-
REQUIRE_THROWS_AS(td.get_rank(std::numeric_limits<double>::infinity()), std::invalid_argument);
518-
}
519-
520-
TEST_CASE("get_rank rejects negative infinity", "[tdigest]") {
521-
tdigest_double td(100);
522-
td.update(1.0);
523-
td.update(2.0);
524-
REQUIRE_THROWS_AS(td.get_rank(-std::numeric_limits<double>::infinity()), std::invalid_argument);
525-
}
526-
527513
TEST_CASE("deserialize bytes rejects NaN single value", "[tdigest]") {
528514
tdigest_double td(100);
529515
td.update(1.0);

0 commit comments

Comments
 (0)