diff --git a/tdigest/include/tdigest_impl.hpp b/tdigest/include/tdigest_impl.hpp index c7128ce9..c47202e6 100644 --- a/tdigest/include/tdigest_impl.hpp +++ b/tdigest/include/tdigest_impl.hpp @@ -35,7 +35,7 @@ tdigest(false, k, std::numeric_limits::infinity(), -std::numeric_limits::i template void tdigest::update(T value) { - // check for NaN + if (std::isnan(value)) return; if (buffer_.size() >= buffer_capacity_ - centroids_.size()) merge_new_values(); buffer_.push_back(centroid(value, 1)); ++buffered_weight_; @@ -89,7 +89,7 @@ uint64_t tdigest::get_total_weight() const { template double tdigest::get_rank(T value) const { if (is_empty()) throw std::runtime_error("operation is undefined for an empty sketch"); - // check for NaN + if (std::isnan(value)) throw std::invalid_argument("operation is undefined for NaN"); if (value < min_) return 0; if (value > max_) return 1; // one centroid and value == min_ == max_