@@ -44,7 +44,7 @@ dp::QuantileTree<double>::Privatized GetPrivatizeTree(
4444 dp_params.mechanism_builder = std::make_unique<dp::GaussianMechanism::Builder>();
4545 } else {
4646 throw py::value_error (" noise_type can be 'laplace' or 'gaussian', but it is '" +
47- noise_type + " './**/ " );
47+ noise_type + " '." );
4848 }
4949 auto status_or_result = tree.MakePrivate (dp_params);
5050 if (!status_or_result.ok ()) {
@@ -89,15 +89,28 @@ void init_algorithms_quantile_tree(py::module& m) {
8989 to_return.mutable_data ()->PackFrom (obj.Serialize ());
9090 return to_return;
9191 });
92- py_class.def (" merge" , &dp::QuantileTree<double >::Merge, py::arg (" summary" ));
92+ py_class.def (
93+ " merge" ,
94+ [](dp::QuantileTree<double >& tree, const dp::Summary& summary) {
95+ if (!summary.has_data ()) {
96+ throw std::runtime_error (" Cannot merge summary, no data." );
97+ }
98+
99+ dp::BoundedQuantilesSummary quantiles_summary;
100+ if (!summary.data ().UnpackTo (&quantiles_summary)) {
101+ throw std::runtime_error (" Fail to upack data" );
102+ }
103+ tree.Merge (quantiles_summary);
104+ },
105+ py::arg (" summary" ));
93106
94107 py_class.def (
95108 " compute_quantiles" ,
96109 [](dp::QuantileTree<double >& tree, double epsilon, double delta,
97- int max_partitions_contributed_to , int max_contributions_per_partition,
110+ int max_partitions_contributed , int max_contributions_per_partition,
98111 const std::vector<double >& quantiles, const std::string& noise_type) {
99112 dp::QuantileTree<double >::Privatized privatized_tree =
100- GetPrivatizeTree (tree, epsilon, delta, max_partitions_contributed_to ,
113+ GetPrivatizeTree (tree, epsilon, delta, max_partitions_contributed ,
101114 max_contributions_per_partition, noise_type);
102115
103116 std::vector<double > output;
@@ -110,7 +123,7 @@ void init_algorithms_quantile_tree(py::module& m) {
110123 }
111124 return output;
112125 },
113- py::arg (" epsilon" ), py::arg (" delta" ), py::arg (" max_partitions_contributed_to " ),
126+ py::arg (" epsilon" ), py::arg (" delta" ), py::arg (" max_partitions_contributed " ),
114127 py::arg (" max_contributions_per_partition" ), py::arg (" quantiles" ),
115128 py::arg (" noise_type" ) = " laplace" , " Compute multiple quantiles." );
116129
0 commit comments