You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by jm...@apache.org on 2020/03/06 00:07:34 UTC

[incubator-datasketches-cpp] 01/01: check for NaN and inifite weights in varopt updates

This is an automated email from the ASF dual-hosted git repository.

jmalkin pushed a commit to branch vo_weight_check
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-cpp.git

commit 1d22c3b500f0ca0df238657bb3f43baee51cbfcb
Author: Jon Malkin <jm...@users.noreply.github.com>
AuthorDate: Thu Mar 5 16:05:46 2020 -0800

    check for NaN and inifite weights in varopt updates
---
 sampling/include/var_opt_sketch_impl.hpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sampling/include/var_opt_sketch_impl.hpp b/sampling/include/var_opt_sketch_impl.hpp
index ddf0716..a36a579 100644
--- a/sampling/include/var_opt_sketch_impl.hpp
+++ b/sampling/include/var_opt_sketch_impl.hpp
@@ -724,8 +724,8 @@ std::string var_opt_sketch<T,S,A>::items_to_string() const {
 
 template<typename T, typename S, typename A>
 void var_opt_sketch<T,S,A>::update(const T& item, double weight, bool mark) {
-  if (weight <= 0.0) { 
-    throw std::invalid_argument("Item weights must be strictly positive. Found: "
+  if (weight <= 0.0 || std::isnan(weight) || std::isinf(weight)) { 
+    throw std::invalid_argument("Item weights must be strictly positive and finite. Found: "
                                 + std::to_string(weight));
   }
   ++n_;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org