@@ -30,8 +30,14 @@ void bind_count_min_sketch(nb::module_ &m, const char* name) {
3030 using namespace datasketches ;
3131
3232 nb::class_<count_min_sketch<W>>(m, name)
33- .def (nb::init<uint8_t , uint32_t , uint64_t >(), nb::arg (" num_hashes" ), nb::arg (" num_buckets" ), nb::arg (" seed" )=DEFAULT_SEED)
34- .def (nb::init<const count_min_sketch<W>&>())
33+ .def (nb::init<uint8_t , uint32_t , uint64_t >(), nb::arg (" num_hashes" ), nb::arg (" num_buckets" ), nb::arg (" seed" )=DEFAULT_SEED,
34+ " Creates an instance of a CountMin sketch\n\n "
35+ " :param num_hashes: Number of rows in the sketch\n :type num_hashes: int\n "
36+ " :param num_buckets: Number of columns in the sketch\n :type num_buckets: int\n "
37+ " :param seed: Hash seed to use\n :type seed: int, optional"
38+ )
39+ // using nun_hashes (rows), num_buckets (columns), and hash seed `seed`.)
40+ .def (" __copy__" , [](const count_min_sketch<W>& sk){ return count_min_sketch<W>(sk); })
3541 .def_static (" suggest_num_buckets" , &count_min_sketch<W>::suggest_num_buckets, nb::arg (" relative_error" ),
3642 " Suggests the number of buckets needed to achieve an accuracy within the provided "
3743 " relative_error. For example, when relative_error = 0.05, the returned frequency estimates "
@@ -50,16 +56,16 @@ void bind_count_min_sketch(nb::module_ &m, const char* name) {
5056 " Produces a string summary of the sketch" )
5157 .def (" is_empty" , &count_min_sketch<W>::is_empty,
5258 " Returns True if the sketch has seen no items, otherwise False" )
53- .def ( " get_num_hashes " , &count_min_sketch<W>::get_num_hashes,
54- " Returns the configured number of hashes for the sketch" )
55- .def ( " get_num_buckets " , &count_min_sketch<W>::get_num_buckets,
56- " Returns the configured number of buckets for the sketch" )
57- .def ( " get_seed " , &count_min_sketch<W>::get_seed,
58- " Returns the base hash seed for the sketch" )
59+ .def_prop_ro ( " num_hashes " , &count_min_sketch<W>::get_num_hashes,
60+ " The configured number of hashes for the sketch" )
61+ .def_prop_ro ( " num_buckets " , &count_min_sketch<W>::get_num_buckets,
62+ " The configured number of buckets for the sketch" )
63+ .def_prop_ro ( " seed " , &count_min_sketch<W>::get_seed,
64+ " The base hash seed for the sketch" )
5965 .def (" get_relative_error" , &count_min_sketch<W>::get_relative_error,
6066 " Returns the maximum permissible error for any frequency estimate query" )
61- .def ( " get_total_weight " , &count_min_sketch<W>::get_total_weight,
62- " Returns the total weight currently inserted into the stream" )
67+ .def_prop_ro ( " total_weight " , &count_min_sketch<W>::get_total_weight,
68+ " The total weight currently inserted into the stream" )
6369 .def (" update" , static_cast <void (count_min_sketch<W>::*)(int64_t , W)>(&count_min_sketch<W>::update), nb::arg (" item" ), nb::arg (" weight" )=1.0 ,
6470 " Updates the sketch with the given 64-bit integer value" )
6571 .def (" update" , static_cast <void (count_min_sketch<W>::*)(const std::string&, W)>(&count_min_sketch<W>::update), nb::arg (" item" ), nb::arg (" weight" )=1.0 ,
@@ -73,9 +79,9 @@ void bind_count_min_sketch(nb::module_ &m, const char* name) {
7379 .def (" get_upper_bound" , static_cast <W (count_min_sketch<W>::*)(const std::string&) const >(&count_min_sketch<W>::get_upper_bound), nb::arg (" item" ),
7480 " Returns an upper bound on the estimate for the provided string" )
7581 .def (" get_lower_bound" , static_cast <W (count_min_sketch<W>::*)(int64_t ) const >(&count_min_sketch<W>::get_lower_bound), nb::arg (" item" ),
76- " Returns an lower bound on the estimate for the given 64-bit integer value" )
82+ " Returns a lower bound on the estimate for the given 64-bit integer value" )
7783 .def (" get_lower_bound" , static_cast <W (count_min_sketch<W>::*)(const std::string&) const >(&count_min_sketch<W>::get_lower_bound), nb::arg (" item" ),
78- " Returns an lower bound on the estimate for the provided string" )
84+ " Returns a lower bound on the estimate for the provided string" )
7985 .def (" merge" , &count_min_sketch<W>::merge, nb::arg (" other" ),
8086 " Merges the provided other sketch into this one" )
8187 .def (" get_serialized_size_bytes" , &count_min_sketch<W>::get_serialized_size_bytes,
0 commit comments