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 2019/09/17 22:51:37 UTC

[incubator-datasketches-cpp] 04/04: kll method python tests, including a fix for the kll wrapper which returend 1 too few values

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

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

commit 47f48d14c20ca2a94d36b5c0d7ba0c997ce63311
Author: jmalkin <jm...@users.noreply.github.com>
AuthorDate: Mon Sep 9 15:27:05 2019 -0700

    kll method python tests, including a fix for the kll wrapper which returend 1 too few values
---
 python/src/kll_wrapper.cpp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/python/src/kll_wrapper.cpp b/python/src/kll_wrapper.cpp
index 195cf64..120c3dd 100644
--- a/python/src/kll_wrapper.cpp
+++ b/python/src/kll_wrapper.cpp
@@ -49,7 +49,7 @@ double kll_sketch_generic_normalized_rank_error(uint16_t k, bool pmf) {
 
 template<typename T>
 py::list kll_sketch_get_quantiles(const kll_sketch<T>& sk,
-                                std::vector<double>& fractions) {
+                                 std::vector<double>& fractions) {
   size_t nQuantiles = fractions.size();
   auto result = sk.get_quantiles(&fractions[0], nQuantiles);
 
@@ -64,12 +64,12 @@ py::list kll_sketch_get_quantiles(const kll_sketch<T>& sk,
 
 template<typename T>
 py::list kll_sketch_get_pmf(const kll_sketch<T>& sk,
-                          std::vector<T>& split_points) {
+                            std::vector<T>& split_points) {
   size_t nPoints = split_points.size();
   auto result = sk.get_PMF(&split_points[0], nPoints);
 
-  py::list list(nPoints);
-  for (int i = 0; i < nPoints; ++i) {
+  py::list list(nPoints + 1);
+  for (int i = 0; i <= nPoints; ++i) {
     list[i] = result[i];
   }
 
@@ -78,12 +78,12 @@ py::list kll_sketch_get_pmf(const kll_sketch<T>& sk,
 
 template<typename T>
 py::list kll_sketch_get_cdf(const kll_sketch<T>& sk,
-                          std::vector<T>& split_points) {
+                            std::vector<T>& split_points) {
   size_t nPoints = split_points.size();
   auto result = sk.get_CDF(&split_points[0], nPoints);
 
-  py::list list(nPoints);
-  for (int i = 0; i < nPoints; ++i) {
+  py::list list(nPoints + 1);
+  for (int i = 0; i <= nPoints; ++i) {
     list[i] = result[i];
   }
 


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