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 2023/01/28 03:15:45 UTC

[datasketches-cpp] 01/01: ensure we use std::abs() everywhere

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

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

commit e46a6072a42907e280fe47974cf37d6f7d64655b
Author: Jon <jm...@apache.org>
AuthorDate: Fri Jan 27 19:15:28 2023 -0800

    ensure we use std::abs() everywhere
---
 kll/test/kll_sketch_test.cpp             | 4 ++--
 quantiles/test/quantiles_sketch_test.cpp | 2 +-
 sampling/include/var_opt_union_impl.hpp  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kll/test/kll_sketch_test.cpp b/kll/test/kll_sketch_test.cpp
index 7ce92c9..1c8356c 100644
--- a/kll/test/kll_sketch_test.cpp
+++ b/kll/test/kll_sketch_test.cpp
@@ -242,7 +242,7 @@ TEST_CASE("kll sketch", "[kll_sketch]") {
           FAIL("checking rank vs CDF for value " + std::to_string(i));
         }
         subtotal_pmf += pmf[i];
-        if (abs(ranks[i] - subtotal_pmf) > NUMERIC_NOISE_TOLERANCE) {
+        if (std::abs(ranks[i] - subtotal_pmf) > NUMERIC_NOISE_TOLERANCE) {
           FAIL("CDF vs PMF for value " + std::to_string(i));
         }
       }
@@ -257,7 +257,7 @@ TEST_CASE("kll sketch", "[kll_sketch]") {
           FAIL("checking rank vs CDF for value " + std::to_string(i));
         }
         subtotal_pmf += pmf[i];
-        if (abs(ranks[i] - subtotal_pmf) > NUMERIC_NOISE_TOLERANCE) {
+        if (std::abs(ranks[i] - subtotal_pmf) > NUMERIC_NOISE_TOLERANCE) {
           FAIL("CDF vs PMF for value " + std::to_string(i));
         }
       }
diff --git a/quantiles/test/quantiles_sketch_test.cpp b/quantiles/test/quantiles_sketch_test.cpp
index 3e47c33..2eb6e04 100644
--- a/quantiles/test/quantiles_sketch_test.cpp
+++ b/quantiles/test/quantiles_sketch_test.cpp
@@ -260,7 +260,7 @@ TEST_CASE("quantiles sketch", "[quantiles_sketch]") {
         REQUIRE(sketch.get_rank(values[i]) == ranks[i]);
       }
       subtotal_pmf += pmf[i];
-      if (abs(ranks[i] - subtotal_pmf) > NUMERIC_NOISE_TOLERANCE) {
+      if (std::abs(ranks[i] - subtotal_pmf) > NUMERIC_NOISE_TOLERANCE) {
         std::cerr << "CDF vs PMF for value " << i << std::endl;
         REQUIRE(ranks[i] == Approx(subtotal_pmf).margin(NUMERIC_NOISE_TOLERANCE));
       }
diff --git a/sampling/include/var_opt_union_impl.hpp b/sampling/include/var_opt_union_impl.hpp
index 1154061..1a9b584 100644
--- a/sampling/include/var_opt_union_impl.hpp
+++ b/sampling/include/var_opt_union_impl.hpp
@@ -543,7 +543,7 @@ void var_opt_union<T, A>::mark_moving_gadget_coercer(var_opt_sketch<T, A>& sk) c
   }
 
   if (result_h + result_r != result_k) throw std::logic_error("H + R counts must equal k");
-  if (fabs(transferred_weight - outer_tau_numer_) > 1e-10) {
+  if (std::abs(transferred_weight - outer_tau_numer_) > 1e-10) {
     throw std::logic_error("uexpected mismatch in transferred weight");
   }
 


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