in src/vector_of_kll.cpp [523:581]
void bind_vector_of_kll_sketches(nb::module_ &m, const char* name) {
using namespace datasketches;
nb::class_<vector_of_kll_sketches<T>>(m, name)
.def(nb::init<uint32_t, uint32_t>(), nb::arg("k")=vector_of_kll_constants::DEFAULT_K,
nb::arg("d")=vector_of_kll_constants::DEFAULT_D,
"Creates a new Vector of KLL Sketches instance with the given values of k and d.\n\n"
":param k: The value of k for every sketch in the vector\n:type k: int\n"
":param d: The number of sketches in the vector\n:type d: int"
)
.def("__copy__", [](const vector_of_kll_sketches<T>& sk){ return vector_of_kll_sketches<T>(sk); })
// allow user to retrieve k or d, in case it's instantiated w/ defaults
.def_prop_ro("k", &vector_of_kll_sketches<T>::get_k,
"The value of `k` of the sketch(es)")
.def_prop_ro("d", &vector_of_kll_sketches<T>::get_d,
"The number of sketches")
.def("update", &vector_of_kll_sketches<T>::update, nb::arg("items"), nb::arg("order") = "C",
"Updates the sketch(es) with value(s). Must be a 1D array of size equal to the number of sketches. Can also be 2D array of shape (n_updates, n_sketches). If a sketch does not have a value to update, use np.nan. "
" Order 'F' specifies a column-major (Fortran style) matrix; any other value assumes row-major (C style) matrix.")
.def("__str__", [](const vector_of_kll_sketches<T>& sk) { return sk.to_string(); },
"Produces a string summary of all sketches. Users should split the returned string by '\\n\\n'")
.def("to_string", &vector_of_kll_sketches<T>::to_string, nb::arg("print_levels")=false,
nb::arg("print_items")=false,
"Produces a string summary of all sketches. Users should split the returned string by '\\n\\n'")
.def("is_empty", &vector_of_kll_sketches<T>::is_empty,
"Returns whether the sketch(es) is(are) empty of not")
.def("get_n", &vector_of_kll_sketches<T>::get_n,
"Returns the number of values seen by the sketch(es)")
.def("get_num_retained", &vector_of_kll_sketches<T>::get_num_retained,
"Returns the number of values retained by the sketch(es)")
.def("is_estimation_mode", &vector_of_kll_sketches<T>::is_estimation_mode,
"Returns whether the sketch(es) is(are) in estimation mode")
.def("get_min_values", &vector_of_kll_sketches<T>::get_min_values,
"Returns the minimum value(s) of the sketch(es)")
.def("get_max_values", &vector_of_kll_sketches<T>::get_max_values,
"Returns the maximum value(s) of the sketch(es)")
.def("get_quantiles", &vector_of_kll_sketches<T>::get_quantiles, nb::arg("ranks"),
nb::arg("isk")=-1,
"Returns the value(s) associated with the specified quantile(s) for the specified sketch(es). `ranks` can be a float between 0 and 1 (inclusive), or a list/array of values. `isk` specifies which sketch(es) to return the value(s) for (default: all sketches)")
.def("get_ranks", &vector_of_kll_sketches<T>::get_ranks,
nb::arg("value"), nb::arg("isk")=-1,
"Returns the value(s) associated with the specified rank(s) for the specified sketch(es). `values` can be an int between 0 and the number of values retained, or a list/array of values. `isk` specifies which sketch(es) to return the value(s) for (default: all sketches)")
.def("get_pmf", &vector_of_kll_sketches<T>::get_pmf, nb::arg("split_points"), nb::arg("isk")=-1,
"Returns the probability mass function (PMF) at `split_points` of the specified sketch(es). `split_points` should be a list/array of floats between 0 and 1 (inclusive). `isk` specifies which sketch(es) to return the PMF for (default: all sketches)")
.def("get_cdf", &vector_of_kll_sketches<T>::get_cdf, nb::arg("split_points"), nb::arg("isk")=-1,
"Returns the cumulative distribution function (CDF) at `split_points` of the specified sketch(es). `split_points` should be a list/array of floats between 0 and 1 (inclusive). `isk` specifies which sketch(es) to return the CDF for (default: all sketches)")
.def_static("get_normalized_rank_error",
[](uint16_t k, bool pmf) { return kll_sketch<T>::get_normalized_rank_error(k, pmf); },
nb::arg("k"), nb::arg("as_pmf"), "Returns the normalized rank error")
.def("serialize", &vector_of_kll_sketches<T>::serialize, nb::arg("isk")=-1,
"Serializes the specified sketch(es). `isk` can be an int or a list/array of ints (default: all sketches)")
.def("deserialize", &vector_of_kll_sketches<T>::deserialize, nb::arg("skBytes"), nb::arg("isk"),
"Deserializes the specified sketch. `isk` must be an int.")
.def("merge", &vector_of_kll_sketches<T>::merge, nb::arg("array_of_sketches"),
"Merges the input array of KLL sketches into the existing array.")
.def("collapse", &vector_of_kll_sketches<T>::collapse, nb::arg("isk")=-1,
"Returns the result of collapsing all sketches in the array into a single sketch. 'isk' can be an int or a list/array of ints (default: all sketches)")
;
}