This is an automated email from the ASF dual-hosted git repository. alsay pushed a commit to branch get_quantiles in repository https://gitbox.apache.org/repos/asf/datasketches-python.git
commit b516794d56ae4387331f11fc6781b08a29f958f8 Author: AlexanderSaydakov <[email protected]> AuthorDate: Wed Nov 8 12:49:59 2023 -0800 fixed get_quantiles() --- src/kll_wrapper.cpp | 10 +++++++--- src/quantiles_wrapper.cpp | 10 +++++++--- src/req_wrapper.cpp | 10 +++++++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/kll_wrapper.cpp b/src/kll_wrapper.cpp index e80e921..aefb33e 100644 --- a/src/kll_wrapper.cpp +++ b/src/kll_wrapper.cpp @@ -71,13 +71,17 @@ void bind_kll_sketch(py::module &m, const char* name) { .def( "get_quantiles", [](const kll_sketch<T, C>& sk, const std::vector<double>& ranks, bool inclusive) { - return sk.get_quantiles(ranks.data(), ranks.size(), inclusive); + std::vector<T> quantiles; + if (!sk.is_empty()) { + quantiles.reserve(ranks.size()); + for (size_t i = 0; i < ranks.size(); ++i) quantiles.push_back(sk.get_quantile(ranks[i], inclusive)); + } + return quantiles; }, py::arg("ranks"), py::arg("inclusive")=false, "This returns an array that could have been generated by using get_quantile() for each " "normalized rank separately.\n" - "If the sketch is empty this returns an empty vector.\n" - "Deprecated. Will be removed in the next major version. Use get_quantile() instead." + "If the sketch is empty this returns an empty vector." ) .def("get_rank", &kll_sketch<T, C>::get_rank, py::arg("value"), py::arg("inclusive")=false, "Returns an approximation to the normalized rank of the given value from 0 to 1, inclusive.\n" diff --git a/src/quantiles_wrapper.cpp b/src/quantiles_wrapper.cpp index c4a9f52..b205cc7 100644 --- a/src/quantiles_wrapper.cpp +++ b/src/quantiles_wrapper.cpp @@ -72,13 +72,17 @@ void bind_quantiles_sketch(py::module &m, const char* name) { .def( "get_quantiles", [](const quantiles_sketch<T, C>& sk, const std::vector<double>& ranks, bool inclusive) { - return sk.get_quantiles(ranks.data(), ranks.size(), inclusive); + std::vector<T> quantiles; + if (!sk.is_empty()) { + quantiles.reserve(ranks.size()); + for (size_t i = 0; i < ranks.size(); ++i) quantiles.push_back(sk.get_quantile(ranks[i], inclusive)); + } + return quantiles; }, py::arg("ranks"), py::arg("inclusive")=false, "This returns an array that could have been generated by using get_quantile() for each " "normalized rank separately.\n" - "If the sketch is empty this returns an empty vector.\n" - "Deprecated. Will be removed in the next major version. Use get_quantile() instead." + "If the sketch is empty this returns an empty vector." ) .def("get_rank", &quantiles_sketch<T, C>::get_rank, py::arg("value"), py::arg("inclusive")=false, "Returns an approximation to the normalized rank of the given value from 0 to 1, inclusive.\n" diff --git a/src/req_wrapper.cpp b/src/req_wrapper.cpp index 30368ab..1fe8b4e 100644 --- a/src/req_wrapper.cpp +++ b/src/req_wrapper.cpp @@ -70,13 +70,17 @@ void bind_req_sketch(py::module &m, const char* name) { .def( "get_quantiles", [](const req_sketch<T, C>& sk, const std::vector<double>& ranks, bool inclusive) { - return sk.get_quantiles(ranks.data(), ranks.size(), inclusive); + std::vector<T> quantiles; + if (!sk.is_empty()) { + quantiles.reserve(ranks.size()); + for (size_t i = 0; i < ranks.size(); ++i) quantiles.push_back(sk.get_quantile(ranks[i], inclusive)); + } + return quantiles; }, py::arg("ranks"), py::arg("inclusive")=false, "This returns an array that could have been generated by using get_quantile() for each " "normalized rank separately.\n" - "If the sketch is empty this returns an empty vector.\n" - "Deprecated. Will be removed in the next major version. Use get_quantile() instead." + "If the sketch is empty this returns an empty vector." ) .def("get_rank", &req_sketch<T, C>::get_rank, py::arg("value"), py::arg("inclusive")=false, "Returns an approximation to the normalized rank of the given value from 0 to 1, inclusive.\n" --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
