-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor DP Auditorium example * Fix dependencies * Fix README PiperOrigin-RevId: 606329824 Change-Id: I425c7d754416664f710f1e46db338d4241d145ef GitOrigin-RevId: f952488cad35fad5b15fb1306d4b62e5e6a79102
- Loading branch information
Showing
10 changed files
with
209 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
python/dp_auditorium/dp_auditorium/examples/run_mean_mechanism_example_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright 2024 Google LLC. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from absl.testing import absltest | ||
import numpy as np | ||
from vizier.service import clients | ||
|
||
from dp_auditorium import interfaces | ||
from dp_auditorium.configs import dataset_generator_config | ||
from dp_auditorium.examples.run_mean_mechanism_example import mean_mechanism_report | ||
from dp_auditorium.generators import vizier_dataset_generator | ||
|
||
|
||
class StubVizierGenerator( | ||
vizier_dataset_generator.VizierScalarDataAddRemoveGenerator | ||
): | ||
|
||
def get_neighboring_datasets_from_vizier_params( | ||
self, vizier_params: np.ndarray | ||
) -> interfaces.NeighboringDatasetsType: | ||
return np.ones(2), np.ones(2) | ||
|
||
|
||
class RunMeanMechanismExampleTest(absltest.TestCase): | ||
|
||
def test_generates_result(self): | ||
clients.environment_variables.servicer_use_sql_ram() | ||
output = mean_mechanism_report( | ||
0.1, | ||
0.1, | ||
1, | ||
lambda config: vizier_dataset_generator.VizierScalarDataAddRemoveGenerator( | ||
config=config | ||
), | ||
) | ||
self.assertNotEmpty(str(output)) | ||
|
||
|
||
if __name__ == "__main__": | ||
absltest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.